1. RFC2616的sec“1.3术语”中“语义透明”的定义
语义透明
A cache behaves in a "semantically transparent" manner, with
respect to a particular response, when its use affects neither the
requesting client nor the origin server, except to improve
performance. When a cache is semantically transparent, the client
receives exactly the same response (except for hop-by-hop headers)
that it would have received had its request been handled directly
by the origin server.
2.我无法理解RFC2616“13.1.3缓存控制机制”的句子
Cache-Control标头允许客户端或服务器传输 请求或响应中的各种指令。这些 指令通常会覆盖默认的缓存算法。 作为一个 一般规则,如果标题之间有任何明显的冲突 值,应用最严格的解释(即, 一个最有可能保持语义透明度的人。)
我在“Cache-Control”标题中混淆那些冲突值。
3.我通过Apache Web服务器测试一些例子
3.1 Web Toponology
Telnet(客户端)< - > HTTP代理(apache在代理模式下工作,S1)< - > Web服务器(Apache,S2)
3.1.1 S1 configurarion(作为缓存代理):
<Location />
ProxyPass http://10.8.1.24:80/
</Location>
<IfModule mod_cache.c>
<IfModule mod_mem_cache.c>
CacheEnable mem /
MCacheSize 4096
MCacheMaxObjectCount 100
MCacheMinObjectSize 1
MCacheMaxObjectSize 2048
</IfModule>
CacheDefaultExpire 86400
</IfModule>
3.1.2 S2配置(作为真实的Web服务器):
<filesMatch "\.(html|png)">
Header set Cache-Control "max-age=5, max-age=15"
</filesMatch>
3.2测试用例
3.2.1两个“最大年龄”值
GET /index.html HTTP/1.1
Host: haha
User-Agent: telnet
HTTP/1.1 200 OK
Date: Wed, 13 Mar 2013 03:40:25 GMT
Server: Apache/2.2.23 (Win32)
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "63e62-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Cache-Control: max-age=5, max-age=35, must-revalidate
Age: 3
Content-Type: text/html
<html><body><h1>It works!</h1></body></html>
应用值“max-age = 5”。 在这里,我认为应用了“max-age = 35”,因为这个值可以在缓存和服务器中存储更长的内容,以便从概念“语义透明度”提高性能的后续请求。
3.2.2 max-age = 35且必须重新验证
GET /index.html HTTP/1.1
Host: haha
User-Agent: telnet
HTTP/1.1 200 OK
Date: Wed, 13 Mar 2013 03:41:24 GMT
Server: Apache/2.2.23 (Win32)
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "63e62-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Cache-Control: max-age=35, must-revalidate
Age: 10
Content-Type: text/html
<html><body><h1>It works!</h1></body></html>
应用值max-age = 35。 在这里,我认为价值“必须重新验证”应该适用。
3.2.3 max-age = 35 and no-store
GET /index.html HTTP/1.1
Host: haha
User-Agent: telnet
HTTP/1.1 200 OK
Date: Wed, 13 Mar 2013 03:45:04 GMT
Server: Apache/2.2.24 (Unix)
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "63e62-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Cache-Control: max-age=35, no-store
Content-Type: text/html
<html><body><h1>It works!</h1></body></html>
应用值“no-store”。
3.2.4 max-age = 36 and no-cache
GET /index.html HTTP/1.1
Host: haha
User-Agent: telnet
HTTP/1.1 200 OK
Date: Wed, 13 Mar 2013 06:22:14 GMT
Server: Apache/2.2.24 (Unix)
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "63e62-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Cache-Control: max-age=35, no-cache
Content-Type: text/html
<html><body><h1>It works!</h1></body></html>
应用值“no-cache”。
参考文献: RFC2616 http://tools.ietf.org/html/rfc2616
答案 0 :(得分:0)
我会解释你给出的例子如下:
max-age=5, max-age=15
:max-age=5
获胜,因为缓存时间更短,限制性更强 max-age=5, max-age=35, must-revalidate
:must-revalidate
获胜,因为它要求客户端始终重新验证请求。 Section 14.9.4说:
The must-revalidate directive is necessary to support reliable
operation for certain protocol features. In all circumstances an
HTTP/1.1 cache MUST obey the must-revalidate directive;
max-age=35, no-store
:no-store
获胜,因为它基本上意味着不应该执行缓存,这当然是最严格的。
max-age=35, no-cache
:no-cache
获胜,因为它与no-store
类似,并且未指定任何字段名称,这意味着缓存不得为后续请求重用响应,这两者中限制性更强。