How can I enable caching for static resources such as CSS and JavaScript files in a Sitecore solution? I need these resources to have the following response header present:
Cache-Control:public, max-age=14400
I have the following settings in web.config with no success.
#1 system.webServer/caching
This breaks Sitecore completely. Returns 500 response code with no error information.
<configuration>
<system.webServer>
<caching enabled="true" enableKernelCache="true">
<profiles>
<add extension=".js" policy="CacheForTimePeriod" duration="365.00:00:00"/>
</profiles>
</caching>
</system.webServer>
</configuration>
#2 system.webServer/staticContent/clientCache
This makes no change to the response headers.
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00"/>
</staticContent>
</system.webServer>
</configuration>
#3 location/system.webServer/staticContent/clientCache
This also makes no change to the response headers.
<configuration>
<location path="themes">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:00:15" />
</staticContent>
</system.webServer>
</location>
</configuration>
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30:00:00" /> </staticContent> </system.webServer> </configuration>