Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome - why is it sending if-modified-since requests?

I have a page with lots of small images (icons). When used with chrome, each time the page is reloaded, chrome requests each icon from the server with if-modified-since header.

All icons are served with expires and max-age headers. Firefox loads images from its cache.

Why is chrome doing that and how can I prevent it?

Thanks

like image 294
user473428 Avatar asked Oct 14 '10 14:10

user473428


3 Answers

Have you checked the request headers?

"‘Cache-Control’ is always set to ‘max-age=0′, no matter if you press enter, f5 or ctrl+f5. Except if you start Chrome and enter the url and press enter."

http://techblog.tilllate.com/2008/11/14/clientside-cache-control/

like image 54
Petteri H Avatar answered Nov 09 '22 05:11

Petteri H


With chrome it matters whether you're refreshing a page or simply visiting it.

When you refresh, chrome will ping the server for each file regardless of whether or not they are already cached. If the file hasn't been modified you should see a 304 Not Modified response. If the file has been modified you'll see a 200 OK response instead.

When not refreshing, cached files will have a 200 OK status but if you look in the size/content column of the network panel you'll see (from cache).

like image 13
Ryan Mohr Avatar answered Nov 09 '22 05:11

Ryan Mohr


Google Chrome will ignore the Expires header if it's not a valid date by the RFC. For instance, it always requires days to be specified as double-digits. 1st of May should be set as "01 May" (not "1 May") and so on. Firefox accepts them, this misleads the user that the problem is at the browser (this case, Chrome) and not the header values themselves.

So, if you are setting the expire date manually (not using mod_expires or something similar to calculate the actual date) I recommend you to check your static file headers using REDbot.

like image 12
Kemal Avatar answered Nov 09 '22 03:11

Kemal