Why does Google Chrome not honor the caching headers?

174 Views Asked by At

This is the header that I send back to my users. It's taken from the Chrome DevTools:

enter image description here

When I close the DevTools and refresh the page, I still get requests for this image in my servers.

Here it's claimed that Google does not honor cache when we refresh the page.

I tried to open the page from a new tab, and the cache worked. Yet when I click the refresh button, Chrome does not honor the cache headers.

My question is, why does Google Chrome act like that? I mean one expects cache headers to be a universal standard to be complied by major browsers. How can I make sure my content would be cahced for performance reasons if Google Chrome disobeys HTTP standard?

1

There are 1 best solutions below

0
On

Because a lot of website has implemented caching incorrectly, and caching headers can not always be relied on. A compromise is to re-download the page if a user does a hard refresh of the page, and what exactly defines that? Well, for some browsers it used to be pressing F5 or Ctrl+R, but simply pressing refresh multiple times might also be enough, because you can not expect users to know about a secret shortcut for a hard refresh – either way, it does not matter much to performance, because users typically do not press refresh unless they actually intend to refresh the page.

Of course, another way is if you check the checkbox that says disable cache in developer tools, causing Chrome to redownload everything, including linked resources; If you remove the checkmark it will instead say the resources were loaded from (memory cache) when refreshing, meaning they was loaded from the browsers cache in accordance with the cache policy of the resource.

Note. Chrome still shows cached requests in the Network tab, but it will show as loaded from (memory cache).

TLS certificate errors can also cause the page not to be cached properly. E.g. If your certificate is self-signed.

Additionally, I can not reproduce the behaviour you mention; that is, only the .html page itself is refreshed when clicking the refresh button – not the linked resources such as: images, video, JavaScript, or CSS – but it could be a bug specific to your version of Chrome. When I press refresh, even multiple times, resources are still loaded from the browser cache in accordance with my websites cache policy. I verified this by monitoring my server log live while refreshing the page. E.g:

watch tail /var/log/xxx/sitename-access.log