Chrome does not cache images / js / css

When Chrome loads my site, it checks the server for updated versions of files before it shows them. (Images / Javascript / CSS) It gets 304 from the server, because I never edit external javascript, css or images.

I want it to display images without even checking the server.

Here are the headers:

Connection:keep-alive Date:Tue, 03 Aug 2010 21:39:32 GMT ETag:"2792c73-b1-48cd0909d96ed" Expires:Thu, 02 Sep 2010 21:39:32 GMT Server:Apache/Nginx/Varnish 

How can I make the server not check the server?

+46
google-chrome caching
Aug 03 '10 at 21:51
source share
6 answers

What do the headers of your queries look like?

Chrome will set max-age: 0 in the header of the Cache-Control request if you press Enter in the location bar . If you visit your page with a hyperlink, it should use the cache as expected.

+77
Apr 27 '11 at 5:30 a.m.
source share

Something that bothered me was ... I had a "disable cache" in the developer tools. Hover over your mouse.

+54
Jan 28 '13 at 17:20
source share

Wow! I have encountered the same problem for quite some time.

I will tell you why you came across this problem. Your headlines are fine. You get 304 because of how you try to refresh the page. There are basically 3 ways -

  • Press enter in the address field. You will see that chrome first reads the file from the cache and does not go to the server at all.

  • Press f5, this will confirm that the file is out of date (perhaps this is how you update)

  • Press Ctrl + f5, this is an unconditional reboot of all static resources.

So, basically - you have to press the return key in the address bar. Let me know if this works.

+51
May 12 '13 at 18:31
source share

For me it was a self-signed certificate:

https://code.google.com/p/chromium/issues/detail?id=110649

Chrome does not cache resources from servers with a self-signed certificate.

+17
Feb 10 '16 at 23:34
source share

If you want Chrome to cache your JS / CSS files, the server needs to set the "Cache-Control" header. It should look like this:

Cache-Control: max-age = 86400 (if you want to cache resources for a day).

+3
Aug 03 '10 at 21:55
source share

I believe what you are looking for

Cache-Control: immutable

0
Jul 07 '17 at 6:57
source share



All Articles