How to use meta tags to turn off caching in all browsers?


You have a webpage. You don’t want it to be cached by a web browser for some security reason. But there is no single <meta> attribute that is followed by all the browsers.  You have to find out the way to use the <meta> tag that completely turns off caching in all browsers.


Add the following code inside your <head> element.

The code:

<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" />


In the modern browsers “cache-control” is used. But considering older browser “pragma” and “expires” are added to the code.

N.B. Cache-control- for HTTP 1.1, Pragma-for HTTP 1.0, and Expires- for proxies.

The content value of “no-cache” lets you specify that caches should revalidate this resource every time. “max-age=0” force to revalidate the resource right away.  In the “expires”, content is a date and time after which the document should be considered expired. Setting an illegal expires date to 0 may be used to force a modification check at each visit. In the next line a date is set to consider the page is expired and send the page to revisit.