RFC2616 HTTP/1.1 Reading Notes

22
RFC2616 HTTP/1.1

description

Recently I finished reading the rfc2616, and have many gains to share

Transcript of RFC2616 HTTP/1.1 Reading Notes

Page 1: RFC2616 HTTP/1.1 Reading Notes

RFC2616 HTTP/1.1

Page 2: RFC2616 HTTP/1.1 Reading Notes

Agenda

RFC2616 HTTP/1.1 概述 基础术语和概念 缓存 工具 讨论

Page 3: RFC2616 HTTP/1.1 Reading Notes

RFC2616 HTTP/1.1 概述 The Hypertext Transfer Protocol

(HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems.

RFC2616 21 个章节 协议参数、消息、请求、响应、实体、连接、

方法、状态码、缓存、 Header

Page 4: RFC2616 HTTP/1.1 Reading Notes

基础术语和概念 连接、消息、请求、响应、资源、实体、

表述、内容协商、变量、客户端、 User Agent 、代理、网关、隧道、缓存、可缓存、显式过期时间、启发式过期时间、语义透明、证言( Validator )

Page 5: RFC2616 HTTP/1.1 Reading Notes

基础术语和概念 HTTP Operation

RequestUserAgent

Response

OriginServer

UserAgent

OriginServer

Request chain

Response chain

Intermediaries: Proxies, gateways, tunnels

Page 6: RFC2616 HTTP/1.1 Reading Notes

基础术语和概念 协议的基本形式

Page 7: RFC2616 HTTP/1.1 Reading Notes

基础术语和概念 协议的基本形式( Augmented BNF )

Name=definition(1#element) 协议的主要组成

Request Message Response Message

Page 8: RFC2616 HTTP/1.1 Reading Notes

基础术语和概念 Request

Response

Page 9: RFC2616 HTTP/1.1 Reading Notes

基础术语和概念 REQUEST 中的方法

OPTIONS GET HEAD POST PUT DELETE TRACE CONNECT

Page 10: RFC2616 HTTP/1.1 Reading Notes

Status Code 状态码 1xx 信息性 2xx 成功性 3xx 重定向 4xx 客户端错误 5xx 服务端错误

Page 11: RFC2616 HTTP/1.1 Reading Notes

HTTP 缓存 Caching would be useless if it did not

significantly improve performance. HTTP/1.1 中缓存的目的

尽量减少发送请求的需求,“截止”机制 尽量减少发送完整响应的需求,“证实”机制

缓存的正确性 与原始服务器检查是等效的 “ 足够新”满足服务器对于更新的需要 适当的 304 、 305 或错误 (4x,5x) 响应消息

Page 12: RFC2616 HTTP/1.1 Reading Notes

Expiration Model

Server-specified Expiration Expires Cache-Control: max-age

Heuristic Expiration 启发式截止 Last-Modified

Page 13: RFC2616 HTTP/1.1 Reading Notes

Expiration Model

Age Calculation Now – data_value Age value

Expiration Calculation Max-age 优先级高于 Expires 有 max-age 没有 max-age

Page 14: RFC2616 HTTP/1.1 Reading Notes

Cache-Control

Cache-Control:max-age=0 Cache-Contro:no-cache

Page 15: RFC2616 HTTP/1.1 Reading Notes

Expiration Model

Original Server

Cache Server 3Expiration:10:03

Cache Server 2Expiration:10:02

Cache Server 1Expiration:10:01

Page 16: RFC2616 HTTP/1.1 Reading Notes

Validation Model

Last-Modified Dates Entity Tag Cache Validators - ETag Weak and Strong Validators

强证言:实体或 Header 变化,证言就发生变化

弱证言:只在语义改变明显时发生变化

Page 17: RFC2616 HTTP/1.1 Reading Notes

工具 工具的用途 常见工具

Firefox Extension Live HTTP Headers IE Http Watch Chrome Developer Tools

Page 18: RFC2616 HTTP/1.1 Reading Notes

LIVE HTTP HEADERS

Page 19: RFC2616 HTTP/1.1 Reading Notes

IE HTPPWATCH

Page 20: RFC2616 HTTP/1.1 Reading Notes

CHROME

Page 21: RFC2616 HTTP/1.1 Reading Notes

展望 Browser Caching 不同服务器缓存类配置比较 缓存的运维控制