Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is meta http-equiv value cache control is not supported?

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

like image 412
Vik2r Avatar asked Jul 24 '13 03:07

Vik2r


People also ask

Which HTTP-equiv prevents the browser from caching the page?

HTTP-EQUIV META tags Pragma: no-cache prevents caching only when used over a secure connection.

What is meta HTTP-equiv Pragma content no-cache?

<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.

What is the use of meta HTTP-equiv?

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.

What is meta HTTP-equiv content type?

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.


2 Answers

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:

  • How to control web page caching, across all browsers?
  • Avoid back button on JSF web application
like image 112
BalusC Avatar answered Oct 21 '22 06:10

BalusC


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.

like image 39
Joe Avatar answered Oct 21 '22 06:10

Joe