jamz.blog

Jamz's Blog

My Links

Archives

Image Galleries

Blog Stats

Caching and IIS HTTP Compression

I have resolved to try and blog a bit more about the useful bits of information I find day to day in order to give a bit back to all those bloggers who have led to my own salvation from so many problems.  So here is today's:

Its fairly undeniable that HTTP compression in IIS 6 is a Good Thing.

However an interesting thing I learned today about HTTP Compression in IIS 6, is that once you turn it on by default it rewrites all the Cache-Control headers of your responses.  This is especially bad if you configure IIS to cache the result of ASPX pages and other dynamic content.

The two offending lines in the IIS Metabase are:

  • HcCacheControlHeader="max-age=86400"
  • HcSendCacheHeaders="TRUE"

Which makes your dynamic content cachable by the client for 24 hours.  You might think you can just change those lines in the file, but you would be wrong - IIS keeps the file locked while its running so its a much better idea to use the adsutil.vbs to modify it.

Run these commands and then do an IISRESET:

  • cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/Filters/Compression/Parameters/HcSendCacheHeaders "FALSE"
  • cscript.exe C:\Inetpub\AdminScripts\adsutil.vbs set /W3SVC/Filters/Compression/Parameters/HcCacheControlHeader "max-age=0"

This will make sure your dynamic content is not cached on the client, however in the mean-time you need to tell all your users to delete their Temporary Internet Files!

Surprisingly it was an article from Intel that led me to this solution.

posted on Friday, March 02, 2007 1:17 PM