浅析HTTP协议

3.         缓存的机制

HTTP/1.1中缓存的目的是为了在很多情况下减少发送请求,同时在许多情况下可以不需要发送完整响应。前者减少了网络回路的数量;HTTP利用一个“过期(expiration)”机制来为此目的。后者减少了网络应用的带宽;HTTP用“验证(validation)”机制来为此目的。

HTTP定义了3种缓存机制:

l Freshness allows a response to be used without re-checking it on the origin server, and can be controlled by both the server and the client. For example, the Expires response header gives a date when the document becomes stale, and the Cache-Control: max-age directive tells the cache how many seconds the response is fresh for.

l Validation can be used to check whether a cached response is still good after it becomes stale. For example, if the response has a Last-Modified header, a cache can make aconditional request using the If-Modified-Since header to see if it has changed.

l Invalidation is usually a side effect of another request that passes through the cache. For example, if URL associated with a cached response subsequently gets a POST, PUT or DELETE request, the cached response will be invalidated.

关于web缓存方面的内容可以参考:Caching Tutorial for Web Authors and Webmasters(英文版)(中文版

4.         响应授权激发机制

这些机制能被用于服务器激发客户端请求并且使客户端授权。

详细的信息请参考:RFC 2617: HTTP Authentication: Basic and Digest Access

后记:

这篇文章只是对HTTP协议做了一个大概介绍,很多细节都有遗漏,请有兴趣的朋友阅读RFC 2616

自己还是一个初学者,有不对的地方还请大家指出。谢谢 :)

 



无觅相关文章插件,快速提升流量