Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser caching - Why does IE9 always show http 304 when actually it did not hit the network?

Tags:

I am trying to set up caching correctly and have set Expires headers to 365 days in the future which is working correctly but not showing correctly in IE9. Does anyone know why?

When you visit any website in IE9 (eg www.google.com) then click Enter in the address bar to revisit it with full caching it shows a lot of extra 304s which Fiddler does not show.

Looking in the network inspector tab (on F12), IE9 shows that it has received 304 Not Modified responses for CSS and JS files and 3 images (possibly images with modified dates within approx past month - the other 30 images not shown are older).

However, according to Fiddler and looking at IIS logs on the server on the website I am developing, it has not actually made these requests. The IE9 network timeline shows these grey 302s as no wait time and "<1 ms" response time - whereas if I hit F5 they are also grey 302s but shown as several milliseconds waiting and downloading time (and they hit the network).

So why does IE9 network inspector think it issued a conditional request for these? Did it actually issue a request that was satisfied within the network stack somewhere, before it got to Fiddler?

Chrome shows all requests, including all images, as grey 200 (from cache) apart from the page itself which is a black 200 (which is correct according to Fiddler and IIS logs).

Firebug shows grey 200 OK for CSS and JS and oddly just one image (also correct assuming grey 200 means from cache - but why show only these resources and not all the other images?)

I've been reading Eric Lawrence's blog posts about IE9 caching and network stack but he doesn't mention this odd behaviour.

like image 761
mike nelson Avatar asked Jan 20 '12 03:01

mike nelson


People also ask

What does the HTTP status code 304 stand for?

The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource.

What causes a 304 error?

An HTTP 304 not modified status code means that the website you're requesting hasn't been updated since the last time you accessed it. Typically, your browser will save (or cache) web pages so it doesn't have to repeatedly download the same information. This is an attempt to speed up page delivery.

Does browser cache automatically?

Just like website servers, browsers cache most content on a page to shorten load times. So, the next time that user loads the page, most of the content is ready to go without needing to download additional data. Browsers also automatically clear cache until their cache is full or their “time to live,” or TTL, expires.


1 Answers

Just to be clear, if you don't see it in Fiddler, it didn't hit the network.

The IE Network tab has a number of bugs-- one of them is that it has a hard time distinguishing between a cache hit satisfied locally (e.g. no network hit) and one that required revalidation with the server (e.g. a 304).

That's because the cache is serviced down in WinINET, well below the Network tab, which lives up above URLMon.

Having said that, here's another reference you may want to check out: IEInternals Blog on Conditional Requests

like image 185
EricLaw Avatar answered Sep 21 '22 12:09

EricLaw