Lagom.nl > Web > IE caching

Internet Explorer caching

One of the stupid bugs in Internet Explorer 6 is that it doesn't correctly handle caching of images and CSS files that are on subdomains without a www prefix, e.g. http://ordbok.lagom.nl/ rather than http://www.lagom.nl/ . Internet Explorer will request and download these files again and again with every page view. Adding the lines below in .htaccess on an Apache server will fix the problem:

BrowserMatch "MSIE" brokenvary=1
BrowserMatch "Opera" !brokenvary
SetEnvIf brokenvary 1 force-no-vary

This is what the logfiles look like when I remove the above lines from .htaccess: IE will re-download the 2550-byte CSS file again every few seconds, as can be seen from response code 200.

213.119.x.x - - [07/Oct/2007:20:23:30 +0200] "GET /obbasic.css HTTP/1.1" 200 2550 "http://ordbok.lagom.nl/vertaal.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
213.119.x.x - - [07/Oct/2007:20:23:48 +0200] "GET /obbasic.css HTTP/1.1" 200 2550 "http://ordbok.lagom.nl/vertaal.cgi/nl" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
213.119.x.x - - [07/Oct/2007:20:23:59 +0200] "GET /obbasic.css HTTP/1.1" 200 2550 "http://ordbok.lagom.nl/vertaal.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"
213.119.x.x - - [07/Oct/2007:20:24:04 +0200] "GET /obbasic.css HTTP/1.1" 200 2550 "http://ordbok.lagom.nl/oversatt.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)"

Below is what it looks like with the htaccess fix. IE still requests the file again and again, even though the web server explicitly tells it to keep the documents in cache for at least 24 hours. But at least the 304 response shows that it doesn't download them because the file wasn't modified since last time (6 seconds before).

62.131.x.x - - [07/Oct/2007:11:00:12 +0200] "GET /obbasic.css HTTP/1.1" 304 0 "http://ordbok.lagom.nl/woord.cgi/nl?q=femton&l=sv" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
62.131.x.x - - [07/Oct/2007:11:00:19 +0200] "GET /obbasic.css HTTP/1.1" 304 0 "http://ordbok.lagom.nl/woord.cgi/nl?q=sexton&l=sv" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
62.131.x.x - - [07/Oct/2007:11:00:24 +0200] "GET /obbasic.css HTTP/1.1" 304 0 "http://ordbok.lagom.nl/woord.cgi/nl?q=sjuton&l=sv" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
62.131.x.x - - [07/Oct/2007:11:00:48 +0200] "GET /obbasic.css HTTP/1.1" 304 0 "http://ordbok.lagom.nl/woord.cgi/nl?q=sjutton&l=sv" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"

It seems that IE 7 doesn't need the fix anymore, but as of October 2007, there are about as many visitors with IE6 as with IE7.

See also: Incutio CSS mailinglist, 2003.


Laatste wijziging: 07 Oct 2007   Copyright