Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome is caching even with HTTP no-cache headers

I am trying to serve a PHP file output with HTTP Headers configured so the content will NOT be served from cache in Chrome.

If I go to Dev tools (in Chrome), and mark the "Disable cache" option, then it works.

But I don't want to depend on that, I hope I can setup HTTP headers in a way I can force Chrome to reload the page everytime.

Here's a screenshot of my current attempt, please note the red marks.

HTTP headers

Could you please provide good documentation or which headers I must declare for this ?

Thanks in advance.

Edit

So I found this other reply too: Chrome caching like a mad browser, but since I recall being told that Chrome needs special headers for Cache-Control, I will keep this question.

like image 465
Niloct Avatar asked Aug 31 '12 18:08

Niloct


People also ask

How do I stop chrome from caching?

When you're in Google Chrome, click on View, then select Developer, then Developer Tools. Alternatively, you can right click on a page in Chrome, then click Inspect. Click on the Network tab, then check the box to Disable cache.

Why is my cache not clearing in Chrome?

Here are some ways you can try to fix your caching problem, in order of escalation: Try holding down the Shift key while pressing the Refresh button. Close your browser and re-open it (make sure you are NOT on the cached page) and delete your temporary Internet files (clear your cache).

What happens if there is no-Cache-Control header?

Without the cache control header the browser requests the resource every time it loads a new(?) page.

How do I adjust Cache-Control without cache?

To use cache-control in HTML, you use the meta tag, e.g. The value in the content field is defined as one of the four values below. HTTP 1.1. Allowed values = PUBLIC | PRIVATE | NO-CACHE | NO-STORE.


1 Answers

Web browsers can cache AJAX requests with the same request parameters. In order to work around this problem, use a query string that changes. One example would be to use the date in seconds as a query parameter.

like image 67
Lucas Holt Avatar answered Oct 17 '22 14:10

Lucas Holt