IIS 7 and Above
disable caching of dynamic content
Last post Mar 03, 2011 12:22 AM by Lloydz
Feb 25, 2011 09:34 PM|cstobbe|LINK
Running IIS 7.0 on Windows Server 2008.
I want to disable client caching of anything requested from a specific directory. Specifically, I want to prevent IIS from returning the
Cache-Control: private header and replace it with Cache-Control: no-cache.
I found the article about
Client Cache <clientCache>. It seems to be exactly what I need except it only works for requests of static content (e.g. html or txt). I want to disable client caching for all content including dynamic content (e.g. php, aspx).
Is this possible? Is it documented somewhere?
Mar 02, 2011 12:13 AM|Lloydz|LINK
You can make specific caching rules for your pages in Output Caching feature. If you do not want to cache file, you can specify the file extension in the rule, untick the "User-mode caching" or choose "Prevent all caching". For details, you can check the
Response caching in IIS7
Mar 02, 2011 05:54 PM|cstobbe|LINK
You can make specific caching rules for your pages in Output Caching feature.
Thank you, but I tried and this does not work. I read the articles you referenced and it is my understanding that the
Output Caching feature controls what IIS caches. I do not care what IIS caches right now. Instead, I want to exercise some influence over how the web browser caches. I want to do this by customizing the value of the
Cache-Control line in the HTTP response header that is returned to the browser. I find that I can use the
HTTP Response Headers feature to add to the Cache-Control line, but IIS inserts a "private" in the Cache-Control line and I cannot find a way to prevent IIS from doing this. (Only if the request is for a static file like .html or .txt can I remove the
Please, any other ideas??
Mar 03, 2011 12:22 AM|Lloydz|LINK
To set "no cache" value for the "Cache-Control" header, based on my experience, you can create an HTTPModule to implement this. Inside the module, catch the response and set "no cache" for it. The code(for c#) used for the setting looks like:
Hope this helps.