I've got an IIS 7.5 site with caching turned on for javascript and css content directories. All requests to these files use a query string with the app version number, so I just want it to cache forever. But I can't get it to work
In IIS, I've get the caching set up, and I see that the responses for the css files come back with the HTTP Header "Cache-Control: max-age=31536000".
However, the browser keeps requesting the file as I browse pages. The server is responding with 304 - Not Modified which is nice, but I want to avoid the round-trip entirely.
The browser REQUEST keeps including the header "Cache-Control: max-age=0". I don't know if that's a helpful clue or not
Etagline in header response? You may want to get rid of it as it is the one that most likely forces browser to send those "If not modified" requests (although I do have them enabled myself and I see browser asking for such file once in a while (usually only after initial request) but not constantly for sure). BTW -- how do you check the headers (that file is cached) -- I hope not by hitting <kbd>F5</kbd> in your browser? If you can -- can you post a link to such site/file? – LazyOne Jul 5 '11 at 17:15Cache-Control: max-age=31622400,public; I do haveEtagand I do not haveExpiresheader .. but I still have all of my static resources cached (lucky me?). Please also do what @cyberx86 suggested: add to web.config:<system.webServer><httpProtocol><customHeaders><add name="Cache-Control" value="public" /></customHeaders></httpProtocol></system.webServer>– LazyOne Jul 5 '11 at 17:39