6

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.

3
  • If this is an ajax request, a hack is to pass a query parameter that uses the date/time in seconds. That way it changes with every request and the browser can't cache it.
    – Lucas Holt
    Aug 31, 2012 at 19:06
  • Exactly what I just coded, will test.
    – Niloct
    Aug 31, 2012 at 19:09
  • It worked =) Thank you, please formalize the answer.
    – Niloct
    Aug 31, 2012 at 19:14

1 Answer 1

7

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.