Disable browser caching with meta HTML tags


To disable browser caching with <meta> tag in HTML, use the following code −

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

HTML lets you specify metadata - additional important information about a document in a variety of ways. The META elements can be used to include name/value pairs describing properties of the HTML document, such as author, expiry date, a list of keywords, document author etc.

The <meta> tag is used to provide such additional information. This tag is an empty element and so does not have a closing tag but it carries information within its attributes.

Example

Let us see a simple example. We have entered the meta http equiv to disable browser caching −

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <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" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Center Div Elements</title>
</head>
<style>
   .mydiv{
      color: red;
      background: yellow;
   }       
</style>
<body>
   <h1>Demo Heading</h1>
   <div class='mydiv'>
      This is demo text.
   </div>
</body>
</html>

Output

Updated on: 06-Dec-2022

14K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements