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
HTTP-EQUIV META tags Pragma: no-cache prevents caching only when used over a secure connection.
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> This directive indicates cached information should not be used and instead requests should be forwarded to the origin server. This directive has the same semantics as the CACHE-CONTROL:NO-CACHE directive and is provided for backwards compatibility with HTTP/1.0.
The http-equiv attribute provides an HTTP header for the information/value of the content attribute. The http-equiv attribute can be used to simulate an HTTP response header.
http-equiv = "content-type" Indicates that the meta element is in the encoding declaration state and represents a character encoding declaration. content = meta-charset string. A specially formatted string providing a character encoding name.
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.
Only some headers are supported through the http-equiv
attribute, and support is different in different browsers. For example, Mozilla only document support for:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With