Common Cache-Control header values:

Det här HTTP header fältet är definierat i RFC 2616

Cache-Control general-header fältet (http huvudet) används för att ange direktiv som måste följas av alla caching mekanismer längs request / response kedjan. I direktiven anges beteende för att förhindra cachar negativt stör begäran eller svar, m.a.o man måste tänka igenom vad man vill ska lagras lokalt hos klienten och det som inte ska göra det. I bland är lokal lagring av data (cache) önskvärt, i bland inte. Publicerat material som sällan eller aldrig ändras ska inte behöva hämtas från server varje gång en klient (som tidigare besökt sidan) begär hämtning av den via en http request. Har du däremot gjort en en TV tablå som ändras minst 1 ggr per dygn så vill man tvinga klienten att hämta data från server då detta med största säkerhet är ändrat sedan klienten sist besökte sidan. Jobbar man med inloggning, databashantering och alla former av inmatningar så vill man inte lagra något lokalt då detta kan hamna i konflikt med data som redan är sparat, risken är stor att man skriver över nytt data med gammalt.

För en utvecklare kan cache direktiv anges på lite olika sätt. Nedanstående exempel visar hur man kan tvinga klienten att alltid hämta från server.

PHP

(Normalt sett tar Apache (Webbserver)/PHP hand om http headern men den kan också skrivas manuellt)

<?php
header($_SERVER["SERVER_PROTOCOL"]." 200 OK");
header("Status: 200 OK");
header("Expires: 0");
header("Pragma: no-cache");
header("Cache-control: no-cache");
header("Content-Type: text/html; charset=utf-8");
print "<!DOCTYPE html>\n<html>osv..";
?>

I CGI-script (Perl)

print "Expires: 0\n";
print "Pragma: no-cache\n";
print "Cache-control: no-cache\n";
print "Content-Type: text/html\n\n";
print "<DOCTYPE html>\n<html>osv..";

I Apache-conf (alternativt .htaccess)

(välj dock metod om apache eller PHP/Perl ska skriva ut headern)

# Cache policy
<Directory "/sökväg/till/publik/mapp/">
Header Set Pragma "no-cache"
Header Set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
Header Set Cache-Control "max-age=0, no-store, no-cache, must-revalidate"
Header Unset ETag
FileETag None
</Directory>

I HTML-koden

<html>
<head>
<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 1970 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body>..</body>
</html>

Cache direktiv måste släppas igenom  av en proxy eller gateway tillämpning, oberoende av deras betydelse för applikationen, eftersom direktiven kan tillämpas på alla mottagare längs request / response kedjan.

  • Cache-Control: no-cache
  • Cache-Control: private
  • Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  • Cache-Control: post-check=0, pre-check=0
  • Cache-Control: no-store, no-cache, must-revalidate
  • Cache-Control: must-revalidate, no-store
  • Cache-Control: no-cache,no-store
  • Cache-Control: max-age=60
  • Cache-Control: no-cache, must-revalidate
  • Cache-Control: no-store
  • Cache-Control: max-age=0, must-revalidate
  • Cache-Control: max-age=0, no-cache
  • Cache-Control: no-cache, no-store, must-revalidate, max-age=0
  • Cache-Control: no-store, no-cache, must-revalidate, max-age=0
  • Cache-Control: store, no-cache, must-revalidate
  • Cache-Control: public
  • Cache-Control: max-age=86400
  • Cache-Control: max-age=0
  • Cache-Control: max-age=2592000
  • Cache-Control: private, max-age=0
  • Cache-Control: private, pre-check=0, post-check=0, max-age=0
  • Cache-Control: max-age=3600
  • Cache-Control: must-revalidate
  • Cache-Control: max-age=3600, public
  • Cache-Control: no-cache, no-store, must-revalidate
  • Cache-Control: max-age=600
  • Cache-Control: no-cache="set-cookie"
  • Cache-Control: private, max-age=0, must-revalidate
  • Cache-Control: must-revalidate = no-cache
  • Cache-Control: no-cache, no-store
  • Cache-Control: private, must-revalidate, max-age=0
  • Cache-Control: max-age=300
  • Cache-Control: private, must-revalidate
  • Cache-Control: Private
  • Cache-Control: max-age=1
  • Cache-Control: max-age=604800
  • Cache-Control: private, no-cache="set-cookie"
  • Cache-Control: "must-revalidate"
  • Cache-Control: max-age=0, no-store
  • Cache-Control: no-cache,no-store,must-revalidate
  • Cache-Control: private, no-cache
  • Cache-Control: no-cache, pre-check=0, post-check=0
  • Cache-Control: public, max-age=10800
  • Cache-Control: max-age=86400, public
  • Cache-Control: must-revalidate, max-age=1
  • Cache-Control: no-cache,must-revalidate
  • Cache-Control: no-store, no-cache
  • Cache-Control: private, max-age=10800, pre-check=10800
  • Cache-Control: No-cache
  • Cache-Control: cache
  • Cache-Control: max-age=1800
  • Cache-Control: max-age=345600
  • Cache-Control: no-cache, must-revalidate, max-age=0
  • Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
  • Cache-Control: no-cache,no-store,max-age=0
  • Cache-Control: no-cache="set-cookie,set-cookie2"
  • Cache-Control: no-store, no-cache, must-revaldate, post-check=1, pre-check=2
  • Cache-Control: pre-check=0, post-check=0, max-age=0
  • Cache-Control: private, post-check=0, pre-check=0, max-age=0
  • Cache-Control: store, no-cache, must-revalidate, post-check=0, pre-check=0
  • Cache-Control: No-Cache
  • Cache-Control: max-age=0, no-cache, no-store
  • Cache-Control: max-age=1209600
  • Cache-Control: no-cache, no-store, must-revalidate, max-age=-1
  • Cache-Control: no-cache, private
  • Cache-Control: no-cache,max-age=0,must-revalidate
  • Cache-Control: post-check=0, pre-check=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  • Cache-Control: ,
  • Cache-Control: max-age=0, private, must-revalidate
  • Cache-Control: max-age=21600
  • Cache-Control: max-age=28800
  • Cache-Control: max-age=5184000
  • Cache-Control: max-age=82800
  • Cache-Control: no-cache, max-age=1
  • Cache-Control: public,max-age=3600
  • Cache-Control: Public
  • Cache-Control: max-age=0, private
  • Cache-Control: max-age=0, private, proxy-revalidate
  • Cache-Control: max-age=120
  • Cache-Control: max-age=18000
  • Cache-Control: max-age=25920000
  • Cache-Control: max-age=31104000
  • Cache-Control: max-age=311040000
  • Cache-Control: max-age=31536000
  • Cache-Control: max-age=3600, private
  • Cache-Control: max-age=900
  • Cache-Control: must-revalidate, no-cache, no-store, private, s-maxage=0, pre-check=0, post-check=0, max-age=0
  • Cache-Control: no-cache, no-store, must-revalidate
  • Cache-Control: no-cache, no-store, private
  • Cache-Control: no-cache,no-transform
  • Cache-Control: no-cache="set-cookie, set-cookie2"
  • Cache-Control: no-store, must-revalidate
  • Cache-Control: no-store, no-cache, must-revalidate, max_age=0
  • Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, private
  • Cache-Control: private, no-cache, max-age=0
  • Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
  • Cache-Control: private, no-store
  • Cache-Control: private, proxy-revalidate
  • Cache-Control: public, max-age=60
  • Cache-Control: public, max-age=604800, post-check=7200, pre-check=604800
  • Cache-Control: 7200
  • Cache-Control: "no-cache"
  • Cache-Control: False
  • Cache-Control: NO-CACHE
  • Cache-Control: No-Store
  • Cache-Control: No-store
  • Cache-Control: max-age=-111581876
  • Cache-Control: max-age=-170009618
  • Cache-Control: max-age=-4366177
  • Cache-Control: max-age=-492324790
  • Cache-Control: max-age=-52613456
  • Cache-Control: max-age=-625447
  • Cache-Control: max-age=-9274207
  • Cache-Control: max-age=0, no-cache, no-store, must-revalidate
  • Cache-Control: max-age=0, no-store, max-age=-2592000
  • Cache-Control: max-age=0, no-store, no-cache, must-revalidate
  • Cache-Control: max-age=0, s-maxage=0, private, must-revalidate
  • Cache-Control: max-age=1, must-revalidate, private
  • Cache-Control: max-age=1, no-cache, must-revalidate
  • Cache-Control: max-age=1, s-maxage=1, no-cache, must-revalidate
  • Cache-Control: max-age=10
  • Cache-Control: max-age=10800
  • Cache-Control: max-age=1200
  • Cache-Control: max-age=124416000
  • Cache-Control: max-age=14400
  • Cache-Control: max-age=172800
  • Cache-Control: max-age=180
  • Cache-Control: max-age=1800,public
  • Cache-Control: max-age=25920
  • Cache-Control: max-age=259200
  • Cache-Control: max-age=2678400, public
  • Cache-Control: max-age=300, must-revalidate
  • Cache-Control: max-age=300, private, proxy-revalidate
  • Cache-Control: max-age=315360000
  • Cache-Control: max-age=3600, s-maxage=3600, no-cache
  • Cache-Control: max-age=43200
  • Cache-Control: max-age=60, must-revalidate
  • Cache-Control: max-age=60, private, proxy-revalidate
  • Cache-Control: max-age=600, must-revalidate
  • Cache-Control: max-age=600, s-maxage=600
  • Cache-Control: max-age=604800, public, proxy-revalidate, must-revalidate
  • Cache-Control: max-age=64800
  • Cache-Control: max-age=7075
  • Cache-Control: max-age=7200
  • Cache-Control: max-age=86400, must-revalidate
  • Cache-Control: max-age=864000
  • Cache-Control: must-revalidate, max-age=0
  • Cache-Control: no - cache
  • Cache-Control: no-Cache
  • Cache-Control: no-cache, max-age=0
  • Cache-Control: no-cache, max-age=2592000
  • Cache-Control: no-cache, max-age=3600
  • Cache-Control: no-cache, max-age=86400
  • Cache-Control: no-cache, must-revalidate, max_age=0
  • Cache-Control: no-cache, must-revalidate, max_age=0, private
  • Cache-Control: no-cache, must-revalidate, no-cache="Set-Cookie", private
  • Cache-Control: no-cache, must-revalidate, no-store, post-check=0, pre-check=0
  • Cache-Control: no-cache, must-revalidate;
  • Cache-Control: no-cache, no-cache, no-cache, no-cache
  • Cache-Control: no-cache, no-store, max-age=0, must-revalidate
  • Cache-Control: no-cache, no-store, max-age=0, private, must-revalidate, proxy-revalidate
  • Cache-Control: no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform, max-age=0
  • Cache-Control: no-cache, no-store, must-revalidate, private
  • Cache-Control: no-cache, no-store, no-transform
  • Cache-Control: no-cache, no-store, private, max-age=0
  • Cache-Control: no-cache, no-store, private, max-age=1, must-revalidate
  • Cache-Control: no-cache, no-store, private, must-revalidate, post-check=0, pre-check=0
  • Cache-Control: no-cache, no-store, proxy-revalidate, must-revalidate
  • Cache-Control: no-cache, nostore
  • Cache-Control: no-cache, post-check=0,pre-check=0, max-age=0, max-age=1
  • Cache-Control: no-cache,must-revalidate, no-store
  • Cache-Control: no-cache,no-store,max-age=0,s-maxage=0,must-revalidate
  • Cache-Control: no-cache,private
  • Cache-Control: no-cache; max-age=0
  • Cache-Control: no-cache=set-cookie
  • Cache-Control: no-cash, must-revalidate
  • Cache-Control: no-store, no-cache, must-revalidate, max-age=0, max-age=0
  • Cache-Control: no-store, no-cache, private
  • Cache-Control: no-store,max-age=0,post-check=0,pre-check=0
  • Cache-Control: no-store,no-cache,must-revalidate, post-check=0, pre-check=0, max_age=0
  • Cache-Control: no-store,no-cache,must-revalidate,max-age=-1
  • Cache-Control: no-store,no-cache,must-revalidate,max-age=0,post-check=0,pre-check=0
  • Cache-Control: no-transform
  • Cache-Control: post-check=-1, pre-check=-1
  • Cache-Control: post-check=3600,pre-check=43200
  • Cache-Control: pre-check=0, post-check=0
  • Cache-Control: private , proxy-revalidate, must-revalidate
  • Cache-Control: private, must-revalidate, no-cache, no-check
  • Cache-Control: private, no-cache, must-revalidate
  • Cache-Control: private, no-cache, must-revalidate, no-store, max-age=0, post-check=0, pre-check=0
  • Cache-Control: private, no-cache, no-store, must-revalidate
  • Cache-Control: private, no-cache, no-store, must-revalidate, max-age=0
  • Cache-Control: private, no-store, must-revalidate
  • Cache-Control: private,max-age=3600
  • Cache-Control: private,no-cache,no-store,max-age=0,must-revalidate,proxy-revalidate
  • Cache-Control: private,no-cache,no-store,must-revalidate
  • Cache-Control: proxy-revalidate, max-age=0, must-revalidate
  • Cache-Control: public, max-age=141456
  • Cache-Control: public, max-age=294
  • Cache-Control: public, max-age=30
  • Cache-Control: public, max-age=300
  • Cache-Control: public, max-age=5
  • Cache-Control: public, must-revalidate
  • Cache-Control: public, must-revalidate, no-cache="Set-Cookie", max-age=300
  • Cache-Control: public, proxy-revalidate, must-revalidate, max-age=157680000
  • Cache-Control: s-maxage=1200, must-revalidate, max-age=0

Relaterade dokument

http://www.http-stats.com/Cache-Control

HTTP_COOKIE (denna site)

 


"cache-control", Hans E Andersson: 2010-12-04 19:07:48, ändrad: 2014-03-24 15:44:34

 

Copyright © 2005 - 2019 HEAP. Alla rätter förbehållna. Integritetspolicy