http - Comment contrôler le cache de page web, dans tous les navigateurs

Mots clés : httpcachinghttpshttp-headerscross-browserhttp

meilleur 3 Réponses http - Comment contrôler le cache de page web, dans tous les navigateurs

vote vote

99

Cache-Control: no-cache, no-store, must-revalidate Pragma: no-cache Expires: 0 
Cache-Control: no-store, must-revalidate Pragma: no-cache Expires: 0 
Cache-Control: no-store, must-revalidate Expires: 0 
Cache-Control: no-store, must-revalidate 
Date: Wed, 24 Aug 2016 18:32:02 GMT Expires: 0 
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1. header("Pragma: no-cache"); // HTTP 1.0. header("Expires: 0"); // Proxies. 
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. response.setHeader("Pragma", "no-cache"); // HTTP 1.0. response.setHeader("Expires", "0"); // Proxies. 
Response.Cache.SetCacheability(HttpCacheability.NoCache);  // HTTP 1.1. Response.Cache.AppendCacheExtension("no-store, must-revalidate"); Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. Response.AppendHeader("Expires", "0"); // Proxies. 
// `response` is an instance of System.Net.Http.HttpResponseMessage response.Headers.CacheControl = new CacheControlHeaderValue {     NoCache = true,     NoStore = true,     MustRevalidate = true }; response.Headers.Pragma.ParseAdd("no-cache"); // We can't use `response.Content.Headers.Expires` directly // since it allows only `DateTimeOffset?` values. response.Content?.Headers.TryAddWithoutValidation("Expires", 0.ToString());  
Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. Response.AppendHeader("Expires", "0"); // Proxies. 
// using Microsoft.Net.Http.Headers Response.Headers[HeaderNames.CacheControl] = "no-cache, no-store, must-revalidate"; Response.Headers[HeaderNames.Expires] = "0"; Response.Headers[HeaderNames.Pragma] = "no-cache"; 
Response.addHeader "Cache-Control", "no-cache, no-store, must-revalidate" ' HTTP 1.1. Response.addHeader "Pragma", "no-cache" ' HTTP 1.0. Response.addHeader "Expires", "0" ' Proxies. 
headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1. headers["Pragma"] = "no-cache" # HTTP 1.0. headers["Expires"] = "0" # Proxies. 
response = make_response(render_template(...)) response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1. response.headers["Pragma"] = "no-cache" # HTTP 1.0. response.headers["Expires"] = "0" # Proxies. 
response["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1. response["Pragma"] = "no-cache" # HTTP 1.0. response["Expires"] = "0" # Proxies. 
request.response.headerlist.extend(     (         ('Cache-Control', 'no-cache, no-store, must-revalidate'),         ('Pragma', 'no-cache'),         ('Expires', '0')     ) ) 
responseWriter.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") // HTTP 1.1. responseWriter.Header().Set("Pragma", "no-cache") // HTTP 1.0. responseWriter.Header().Set("Expires", "0") // Proxies. 
(require '[ring.util.response :as r]) (-> response   (r/header "Cache-Control" "no-cache, no-store, must-revalidate")   (r/header "Pragma" "no-cache")   (r/header "Expires" 0)) 
<IfModule mod_headers.c>     Header set Cache-Control "no-cache, no-store, must-revalidate"     Header set Pragma "no-cache"     Header set Expires 0 </IfModule> 
<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"> 
vote vote

89

Cache-Control: no-store <body onunload=""> 
vote vote

76

<configuration> <system.webServer>     <httpProtocol>         <customHeaders>             <add name="Cache-Control" value="no-cache, no-store, must-revalidate" />             <!-- HTTP 1.1. -->             <add name="Pragma" value="no-cache" />             <!-- HTTP 1.0. -->             <add name="Expires" value="0" />             <!-- Proxies. -->         </customHeaders>     </httpProtocol> </system.webServer> 
app.use(function(req, res, next) {     res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');     res.setHeader('Pragma', 'no-cache');     res.setHeader('Expires', '0');     next(); }); 

Questions similaires