TL;DR - I want the server (IIS 8.5) to return 304 not modified for the CSS and JS bundles.
I've been unable to get IIS 8.5 to honor the clientCache settings in web.config. No matter what I do, I can't seem to get it to cache the static content. This is a MVC5 app in VS2013. I've got all the static files in a folder "Assets".
The request looks like: http://someserver/AppName/Assets/mainjs?v=FNj_9ZPAbYVAQsyDo2F8XUnWv5NQpY4iX2RGu4NpJ5g1
- Attempt #1, place a new web.config in the Assets folder with the following:
<configuration> <system.webServer> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" /> </staticContent> </system.webServer> </configuration>
- Attempt #2: place this following configuration in the root web.config
<staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" /> </staticContent>
- Attempt #3: trying setting the cache using the location tag
<location path="Assets"> <system.webServer> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" /> </staticContent> </system.webServer> </location>
Here are the things I've tried in IIS 8.5 manager. Under the Default Web Site/TestApp
- HTTP Requeset Headers, Set Common HTTP Headers, check "Expire Web Content" "After 365 Day(s)".
- Apply the same setting to the "Assets" folder
I've tried these steps each on their own and all together and every other which way. No matter what, it won't add the max-age
value to Cache-Control.
For each of these, the browswer returns 200 responses for the CSS and JS bundles. I cannot get the server cache the content coming from the Assets folder.
Cache-Control:private
Content-Encoding:gzip
Content-Length:22591
Content-Type:text/css; charset=utf-8
Date:Mon, 02 Feb 2015 21:49:49 GMT
Expires:Tue, 02 Feb 2016 21:49:49 GMT
Last-Modified:Mon, 02 Feb 2015 21:49:49 GMT
Persistent-Auth:true
Server:Microsoft-IIS/8.5
Vary:Accept-Encoding
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET