457
votes

I read that when you don't have access to the web server's headers you can turn off the cache using:

<meta http-equiv="Cache-Control" content="no-store" />

But I also read that this doesn't work in some versions of IE. Are there any set of <meta> tags that will turn off cache in all browsers?

6
a combination of bobince and dpb's answers is your best bet. covers all bases.nickf
i18nguy.com/markup/metatags.html On this site is written to preferable deactivate caching in HTTP, so that the site isn't stored on intermediate servers. Thought it might help someone.Bodo
For those struggling with back button and "re-opening closed tab" caching as I am, have a look at this answer from another question. It's hacky, but no header-based solution was working for me and for my purposes this little JS snippet is great (easy to convert to plain JS).user993683
The answers here are all sad. I would add my own, but this is closed. According to MDN: developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control you do in fact most likely want to use <meta http-equiv="Cache-Control" content="no-store"/> as in the question.Andrew

6 Answers

732
votes

For modern web browsers (After IE9)

See the Duplicate listed at the top of the page for correct information!

See answer here: How to control web page caching, across all browsers?


For IE9 and before

Do not blindly copy paste this!

The list is just examples of different techniques, it's not for direct insertion. If copied, the second would overwrite the first and the fourth would overwrite the third because of the http-equiv declarations AND fail with the W3C validator. At most, one could have one of each http-equiv declarations; pragma, cache-control and expires. These are completely outdated when using modern up to date browsers. After IE9 anyway. Chrome and Firefox specifically does not work with these as you would expect, if at all.

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

Actually do not use these at all!

Caching headers are unreliable in meta elements; for one, any web proxies between the site and the user will completely ignore them. You should always use a real HTTP header for headers such as Cache-Control and Pragma.

81
votes

According to Independent Security Evaluators' great case study on the industry-wide misunderstanding of controlling caches, only Cache-Control: no-store is recognized by Chrome, Firefox, and IE. IE recognizes other controls, but Chrome and Firefox do not.

24
votes

It doesn't work in IE5, but that's not a big issue.

However, cacheing headers are unreliable in meta elements; for one, any web proxies between the site and the user will completely ignore them. You should always use a real HTTP header for headers such as Cache-Control and Pragma.

7
votes

pragma is your best bet:

<meta http-equiv="Pragma" content="no-cache">
7
votes

I noticed some caching issues with service calls when repeating the same service call (long polling). Adding metadata didn't help. One solution is to pass a timestamp to ensure ie thinks it's a different http service request. That worked for me, so adding a server side scripting code snippet to automatically update this tag wouldn't hurt:

<meta http-equiv="expires" content="timestamp">

-5
votes

Try using

    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="-1">