Today I learned that Internet Explorer isn't caching any images from my blog at all. Why? A nasty bug in MSIE that mod_gzip triggers. Gory details and a partial fix below.

The issue is that mod_gzip includes the following header in all responses:

Vary: Accept-Encoding
This helps prevent caches from serving gzip data to browsers that can't support it.

Unfortunately it also triggers a bug in MSIE - the browser won't cache any document with that header! So with mod_gzip 95% of the world's browsers won't cache any pages from the server. Some bandwidth savings.

It'd be nice if mod_gzip was smart enough not to add the Vary: header if it didn't compress the file, but it's not. A partial workaround is to turn mod_gzip off for files it won't be compressing anyway, like images.

<FilesMatch "\.(gif|jpe?g|png)$">
mod_gzip_on No
</FilesMatch>
This fix is only partial; other files (say, HTML) still won't be cached. Three choices - stop using gzip, lose caching in IE, or drop the Vary: header and break caches.
tech
  2003-05-18 16:56 Z