Old style cache control
What if you want your page to be checked once per day, whatever are browser settings? Or every time the page is visited, although this is a bad idea for statics? HTTP/1.0 has the Expires clause, that allows web servers to specify a date/time after which the entity should be considered out of date and checked by browsers. Using Expires the web designer can control how fresh each entity is, instead of relying on browser's and proxie's good will — and still using cache advantages.
Now imagine two users sharing their ISP's proxy. As result of one happy coincidence they are going to visit a new page with expiration set by the server; first request is made by Mr.Fox:
GET /cache/static2/testpage.html HTTP/1.1
User-Agent: Mozilla/5.0 Gecko/20060410 Firefox/1.0.8
HTTP/1.1 200 OK
Last-Modified: Fri, 08 Sep 2006 20:09:37 GMT
ETag: "4a1f-4b9-c99ec240"
Expires: Sun, 10 Sep 2006 06:12:57 GMT
X-Cache: MISS from localhost
(show all) +++GET 1503+++
Using Proxy - localhost:8088
GET /cache/static2/testpage.html HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 Gecko/20060410 Firefox/1.0.8
Referer: http://localhost/cache/index.html
+++RESP 1503+++
HTTP/1.1 200 OK
Date: Sun, 10 Sep 2006 06:11:57 GMT
Server: Apache/2.0.58 (Win32) PHP/5.1.4
Last-Modified: Fri, 08 Sep 2006 20:09:37 GMT
ETag: "4a1f-4b9-c99ec240"
Accept-Ranges: bytes
Content-Length: 1209
Cache-Control: max-age=60
Expires: Sun, 10 Sep 2006 06:12:57 GMT
Content-Type: text/html
X-Cache: MISS from localhost
X-Cache-Lookup: MISS from localhost:8088
Via: 1.0 localhost:8088 (squid/2.6.STABLE3-NT)
+++CLOSE 1503+++
(show less) The proxy never seen that page, so will fetch it from the server or other proxy and send it to the browser, reporting (or omitting) a "MISS". While the page is considered fresh Mr.Fox can navigate anywhere and, if returns to the page, will get it from his own cache. More, if Mr.Smith requests the same page in that period of time he will get it from proxy cache:
GET /cache/static2/testpage.html HTTP/1.0
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0)
HTTP/1.0 200 OK
Last-Modified: Fri, 08 Sep 2006 20:09:37 GMT
ETag: "4a1f-4b9-c99ec240"
Expires: Sun, 10 Sep 2006 06:12:57 GMT
X-Cache: HIT from localhost
(show all) +++GET 1504+++
Using Proxy - localhost:8088
GET /cache/static2/testpage.html HTTP/1.0
Referer: http://localhost/cache/index.html
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0)
Host: localhost
+++RESP 1504+++
HTTP/1.0 200 OK
Date: Sun, 10 Sep 2006 06:11:57 GMT
Server: Apache/2.0.58 (Win32) PHP/5.1.4
Last-Modified: Fri, 08 Sep 2006 20:09:37 GMT
ETag: "4a1f-4b9-c99ec240"
Accept-Ranges: bytes
Content-Length: 1209
Cache-Control: max-age=60
Expires: Sun, 10 Sep 2006 06:12:57 GMT
Content-Type: text/html
Age: 40
X-Cache: HIT from localhost
X-Cache-Lookup: HIT from localhost:8088
Via: 1.0 localhost:8088 (squid/2.6.STABLE3-NT)
+++CLOSE 1504+++
(show less) Notice that, if the page's period of validity is 60 seconds and Mr.Smith visits it 40 seconds after Mr.Fox, Mr.Smith's browser will see it as valid for 20 seconds. After the page is considered out of date, if someone using the proxy tries to access the page, proxy will check it with server and the answer will be available to any user:
GET /cache/static2/testpage.html HTTP/1.0
If-Modified-Since: Fri, 08 Sep 2006 20:09:37 GMT
If-None-Match: "4a1f-4b9-c99ec240"
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0)
HTTP/1.0 304 Not Modified
ETag: "4a1f-4b9-c99ec240"
Expires: Sun, 10 Sep 2006 06:20:03 GMT
X-Cache: MISS from localhost
(show all) +++GET 1505+++
Using Proxy - localhost:8088
GET /cache/static2/testpage.html HTTP/1.0
Referer: http://localhost/cache/index.html
If-Modified-Since: Fri, 08 Sep 2006 20:09:37 GMT
If-None-Match: "4a1f-4b9-c99ec240"
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0)
Host: localhost
+++RESP 1505+++
HTTP/1.0 304 Not Modified
Date: Sun, 10 Sep 2006 06:19:03 GMT
Server: Apache/2.0.58 (Win32) PHP/5.1.4
ETag: "4a1f-4b9-c99ec240"
Expires: Sun, 10 Sep 2006 06:20:03 GMT
Cache-Control: max-age=60
X-Cache: MISS from localhost
X-Cache-Lookup: HIT from localhost:8088
Via: 1.0 localhost:8088 (squid/2.6.STABLE3-NT)
+++CLOSE 1505+++
+++GET 1506+++
Using Proxy - localhost:8088
GET /cache/static2/testpage.html HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 Gecko/20060410 Firefox/1.0.8
Referer: http://localhost/cache/
If-Modified-Since: Fri, 08 Sep 2006 20:09:37 GMT
If-None-Match: "4a1f-4b9-c99ec240"
+++RESP 1506+++
HTTP/1.1 304 Not Modified
Date: Sun, 10 Sep 2006 06:19:03 GMT
Content-Type: text/html
Expires: Sun, 10 Sep 2006 06:20:03 GMT
Last-Modified: Fri, 08 Sep 2006 20:09:37 GMT
ETag: "4a1f-4b9-c99ec240"
Age: 48
X-Cache: HIT from localhost
X-Cache-Lookup: HIT from localhost:8088
Via: 1.0 localhost:8088 (squid/2.6.STABLE3-NT)
+++CLOSE 1530+++
(show less)
0 Comments:
Post a Comment
<< Home