Wednesday, 24 June 2020

Use HTML Meta Tags to Disable Caching in Web Browsers

HTML 

The following set of <meta> tags can be used to avoid caching in most of web browsers. They must be in the <head> tag.

<head>
    <!-- other tags... -->
    <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'>
    <!-- other tags... -->
</head>

For HTTP/1.1, the cache-control meta is used for caches. The meanings of the values for the cache-control meta are:

  • no-cache: the stored reponse must always need validation with the origin server before being used
  • no-store: prevent the response stored in any cache
  • must-revalidate: caches must need successful validation with the origin server once a resource becomes stale

But for HTTP/1.0, the pragma meta behaves the same as cache-control: no-cache. Setting the date value of the expires meta to 0 is used to cause the browser to reload the document.




Search