1

When you are in the development stage it's a bit embarrassing to constantly remind your clients to clear the cache or to ask them to "refresh the page a bunch of times."

Is there a setting that I, the developer, can set in nginx or as a meta tag in the HTML to force all browsers to stop caching my page?

TheOne
  • 10,819
  • 20
  • 81
  • 119
  • Not strictly a duplicate, but pretty darn similar to http://stackoverflow.com/questions/118884/what-is-an-elegant-way-to-force-browsers-to-reload-cached-css-js-files?rq=1 – Paul Tomblin Jan 09 '14 at 14:40

2 Answers2

3

Theoretically, according to Difference between Pragma and Cache-control headers? and also http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32, the following may be sufficient, in nginx:

add_header  Cache-Control   no-cache;

In practice, you might have to specify some extra directives; it would seem like using the expires directive should be sufficient, which will automatically add the Cache-Control header as above, too:

expires -1;
Community
  • 1
  • 1
cnst
  • 25,870
  • 6
  • 90
  • 122
2

Try setting these headers:

"Cache-control: no-store, no-cache, must-revalidate"
"Expires: Mon, 26 Jun 1997 05:00:00 GMT"
"Pragma: no-cache"
"Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"

This will prevent the browsers from cashing the pages.

Shahe
  • 964
  • 2
  • 13
  • 34