6

i have this code here on a page:

<!-- no cache headers -->
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<!-- end no cache headers -->

when i go to other page and hit back button of browser (back to the page where this code written), it is still had the cache state of the page. option is, to add PhaseListener but they told me that adding PhaseListener is an additional codes to maintain.
The question is:
1. is meta tag attribute http-equiv value cache-control is still supported in html in all browser?? because when i check in w3school, there is no value cache-control, pragma, and expires for attribute http-equiv.
2. if i add phaseListener what would be the advantage against adding meta tags in every page.?
Thanks ahead

Vik2r
  • 135
  • 1
  • 2
  • 7

2 Answers2

8

The <meta http-equiv> tags are only used when the HTML file in question is been opened from a non-HTTP resource such as local disk file system (via file:// URI) and not when the HTML file in question is been opened from a real HTTP resource (via http:// URI). Instead, the real HTTP response headers as set via HttpServletResponse#setHeader() are been used.

So, your concrete problem is caused because those <meta http-equiv> tags are ignored.

See also:

Community
  • 1
  • 1
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
1

Only some headers are supported through the http-equiv attribute, and support is different in different browsers. For example, Mozilla only document support for:

  • content-language
  • Content-Security-Policy
  • content-type
  • default-style
  • refresh
  • set-cookie

The intention was for servers to parse this header (meta http-equiv - is it sent as part of an HTTP header, or does the client parse the body for meta tags?), but this was never widely implemented. It is implemented by Apache httpd's mod_proxy:

The other effect of enabling ProxyHTMLMeta is to parse all <meta http-equiv=...> declarations and convert them to real HTTP headers, in keeping with the original purpose of this form of the HTML <meta> element.

Using <meta> tags to turn off caching in all browsers? suggests a format that may work in more browsers but, in general, this is not a supported technique.

Community
  • 1
  • 1
Joe
  • 23,380
  • 9
  • 61
  • 75