0

I have a "Refresh" button on my PHP page that uses Javascrip (window.location.reload()) so the user can update the page.

Unfortunately the page includes a number Javascript and CSS libraries (eg. jQuery) that get reloaded too with this kind of refresh.

The libraries are servered with a far future Expires: header and when the user simply requests the main URL, Firefox doesn't reload the libs. But with the refresh button, Firefox sends a "Cach-Control: max-age: 0" header and all libs get reloaded.

Gene Vincent
  • 5,237
  • 9
  • 50
  • 86
  • Maybe this answer can help you [how to set cache for css/js file][1] [1]: http://stackoverflow.com/questions/2537185/how-to-set-cache-for-css-js-file#2538387 – fermin Jul 07 '14 at 08:38
  • I'm already sending Expires and Cache-Control headers similar to that answer. But the max-age:0 from Firefox kills it all... – Gene Vincent Jul 07 '14 at 08:43
  • 1
    if you change button javascript to href="#" ? or maybe change window.location.href ¿? – fermin Jul 07 '14 at 08:46

1 Answers1

0

I had to disable ETags (ETags none) to get the caching to work, so the server will respond with a 304 to the library requests.

Changing the button to a <a href="<?php echo "$_SERVER[SCRIPT_NAME]" ?>">Refresh</a> got ride of the requests.

Gene Vincent
  • 5,237
  • 9
  • 50
  • 86