banner



When Does Google Update Cached Pages

Introduction

The correct minimum set of headers that works beyond all mentioned clients (and proxies):

          Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0                  

The Enshroud-Control is per the HTTP 1.1 spec for clients and proxies (and implicitly required past some clients next to Expires). The Pragma is per the HTTP 1.0 spec for prehistoric clients. The Expires is per the HTTP one.0 and 1.1 specs for clients and proxies. In HTTP 1.1, the Cache-Control takes precedence over Expires, and so it'southward after all for HTTP 1.0 proxies only.

If you lot don't care about IE6 and its broken caching when serving pages over HTTPS with merely no-shop, and so you could omit Cache-Command: no-cache.

          Cache-Control: no-shop, must-revalidate Pragma: no-cache Expires: 0                  

If you don't intendance about IE6 nor HTTP 1.0 clients (HTTP 1.1 was introduced in 1997), then you could omit Pragma.

          Cache-Control: no-store, must-revalidate Expires: 0                  

If you don't intendance about HTTP i.0 proxies either, and then you could omit Expires.

          Enshroud-Command: no-store, must-revalidate                  

On the other manus, if the server automobile-includes a valid Date header, then you could theoretically omit Cache-Command as well and rely on Expires only.

          Engagement: Wednesday, 24 Aug 2016 18:32:02 GMT Expires: 0                  

But that may fail if e.g. the end-user manipulates the operating organization engagement and the client software is relying on it.

Other Enshroud-Command parameters such as max-age are irrelevant if the abovementioned Cache-Control parameters are specified. The Final-Modified header equally included in most other answers here is merely interesting if you actually want to enshroud the request, and then you don't need to specify it at all.

How to gear up it?

Using PHP:

          header("Cache-Command: no-cache, no-shop, must-revalidate"); // HTTP i.i. header("Pragma: no-cache"); // HTTP ane.0. header("Expires: 0"); // Proxies.                  

Using Coffee Servlet, or Node.js:

          response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP ane.0. response.setHeader("Expires", "0"); // Proxies.                  

Using ASP.Cyberspace-MVC

          Response.Cache.SetCacheability(HttpCacheability.NoCache);  // HTTP 1.1. Response.Cache.AppendCacheExtension("no-store, must-revalidate"); Response.AppendHeader("Pragma", "no-cache"); // HTTP one.0. Response.AppendHeader("Expires", "0"); // Proxies.                  

Using ASP.NET Spider web API:

          // `response` is an instance of Organization.Net.Http.HttpResponseMessage response.Headers.CacheControl = new CacheControlHeaderValue {     NoCache = truthful,     NoStore = true,     MustRevalidate = truthful }; response.Headers.Pragma.ParseAdd("no-cache"); // We tin can't use `response.Content.Headers.Expires` directly // since information technology allows only `DateTimeOffset?` values. response.Content?.Headers.TryAddWithoutValidation("Expires", 0.ToString());                  

Using ASP.Internet:

          Response.AppendHeader("Cache-Command", "no-cache, no-store, must-revalidate"); // HTTP 1.1. Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. Response.AppendHeader("Expires", "0"); // Proxies.                  

Using ASP.Net Core v3

          // using Microsoft.Net.Http.Headers Response.Headers[HeaderNames.CacheControl] = "no-cache, no-shop, must-revalidate"; Response.Headers[HeaderNames.Expires] = "0"; Response.Headers[HeaderNames.Pragma] = "no-cache";                  

Using ASP:

          Response.addHeader "Enshroud-Command", "no-cache, no-shop, must-revalidate" ' HTTP ane.1. Response.addHeader "Pragma", "no-cache" ' HTTP ane.0. Response.addHeader "Expires", "0" ' Proxies.                  

Using Blood-red on Rails:

          headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1. headers["Pragma"] = "no-cache" # HTTP ane.0. headers["Expires"] = "0" # Proxies.                  

Using Python/Flask:

          response = make_response(render_template(...)) response.headers["Cache-Command"] = "no-cache, no-store, must-revalidate" # HTTP i.1. response.headers["Pragma"] = "no-cache" # HTTP 1.0. response.headers["Expires"] = "0" # Proxies.                  

Using Python/Django:

          response["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP one.1. response["Pragma"] = "no-enshroud" # HTTP 1.0. response["Expires"] = "0" # Proxies.                  

Using Python/Pyramid:

          request.response.headerlist.extend(     (         ('Cache-Control', 'no-cache, no-store, must-revalidate'),         ('Pragma', 'no-enshroud'),         ('Expires', '0')     ) )                  

Using Go:

          responseWriter.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") // HTTP 1.1. responseWriter.Header().Set("Pragma", "no-cache") // HTTP ane.0. responseWriter.Header().Prepare("Expires", "0") // Proxies.                  

Using Clojure (require Ring utils):

          (crave '[ring.util.response :every bit r]) (-> response   (r/header "Cache-Command" "no-cache, no-store, must-revalidate")   (r/header "Pragma" "no-cache")   (r/header "Expires" 0))                  

Using Apache .htaccess file:

          <IfModule mod_headers.c>     Header set Cache-Control "no-cache, no-store, must-revalidate"     Header set Pragma "no-cache"     Header set up Expires 0 </IfModule>                  

Using HTML:

          <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 meta tags vs HTTP response headers

Important to know is that when an HTML page is served over an HTTP connexion, and a header is present in both the HTTP response headers and the HTML <meta http-equiv> tags, and so the 1 specified in the HTTP response header will get precedence over the HTML meta tag. The HTML meta tag will merely be used when the page is viewed from a local disk file system via a file:// URL. See as well W3 HTML spec chapter five.2.2. Take care with this when you don't specify them programmatically because the webserver tin namely include some default values.

More often than not, y'all'd better merely not specify the HTML meta tags to avoid confusion by starters and rely on hard HTTP response headers. Moreover, specifically those <meta http-equiv> tags are invalid in HTML5. Only the http-equiv values listed in HTML5 specification are allowed.

Verifying the actual HTTP response headers

To verify the one and the other, you tin come across/debug them in the HTTP traffic monitor of the web browser's developer toolset. You can get there by pressing F12 in Chrome/Firefox23+/IE9+, and then opening the "Network" or "Net" tab panel, and and so clicking the HTTP asking of involvement to uncover all particular most the HTTP asking and response. The below screenshot is from Chrome:

Chrome developer toolset HTTP traffic monitor showing HTTP response headers on stackoverflow.com

I want to set those headers on file downloads too

Get-go of all, this question and answer are targeted on "web pages" (HTML pages), non "file downloads" (PDF, zero, Excel, etc). You'd improve have them cached and make use of some file version identifier somewhere in the URI path or query cord to force a redownload on a changed file. When applying those no-cache headers on file downloads anyway, then beware of the IE7/viii issues when serving a file download over HTTPS instead of HTTP. For detail, run into IE cannot download foo.jsf. IE was not able to open this internet site. The requested site is either unavailable or cannot exist constitute.

Source: https://stackoverflow.com/questions/49547/how-do-we-control-web-page-caching-across-all-browsers

Posted by: richardsheith1954.blogspot.com

0 Response to "When Does Google Update Cached Pages"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel