8

I have the following meta tags that supposedly prevents browser caching

<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />

Does this prevent a caching server from holding the content as well, if it doesn't, is there a way to prevent router/server caching?

kylex
  • 13,335
  • 30
  • 103
  • 169

3 Answers3

7

from here

Why META Cache Controls Don't Always Work

Note that the META tags in our example both used the HTTP-EQUIV attribute, which tries to mimic HTTP header information. HTTP headers control how both browser and proxy caches handle your Web pages. They are invisible in HTML and usually generated automatically by your Web server.

You are better off using HTTP headers for setting the cache property. References

http://support.microsoft.com/kb/234067

http://www.htmlgoodies.com/beyond/reference/article.php/3472881

ram
  • 11,033
  • 16
  • 59
  • 86
5

No, it won't prevent proxy caching, and neither will any meta tag. You need to send the HTTP header Cache-Control: no-cache.

http://www.w3.org/Protocols/HTTP/Issues/cache-private.html

See also: http://www.mnot.net/cache_docs/#META

glomad
  • 5,421
  • 2
  • 22
  • 38
  • "http-equiv" elements are picked up by the http server, and included in the http header as part of the response. (http://www.w3.org/TR/html401/struct/global.html): "The http-equiv attribute has a special significance when documents are retrieved via the Hypertext Transfer Protocol (HTTP). HTTP servers may use the property name specified by the http-equiv attribute to create an [RFC822]-style header in the HTTP response." – Ian Boyd Feb 04 '10 at 15:57
  • You just have to decide on the proper http/http-equiv header entry. In this case it seems that `Cache-Control: no-cache` is correct one, which could be added as ``. But in the end it seems that `Pragma: no-cache` is an alias for `Cache-Control: no-cache`. – Ian Boyd Feb 04 '10 at 15:58
  • Notice the word "may" in there. They may, but they often don't. And anyway, that does not help with proxy servers. Proxies will almost always ignore meta tags, including cache directives. – glomad Feb 04 '10 at 16:04
0

It is supposed to prevent that. If the writers of the caching server have written it to respect these tags.

There is no guarantee that this will be respected, but a well written caching server that follows standards should respect these tags.

Oded
  • 463,167
  • 92
  • 837
  • 979