- 消息格式: start line + headers + body
Request Message:
<method> <request-URL> <version>
<headers>
<entity-body>
Repsonse Message:
<version> <status> <reason-phrase>
<headers>
<entity-body>
2.一共7种Method
- 一共5大类Status Code
4.基于TCP的HTTP问题
如果采用TCP短连接会带来较大的延迟,原因:
- TCP 三次握手(handshake)
- TCP 延时确认(delay ack)
- TCP 慢启动(slow start)
- 服务器端频繁关闭TCP,导致TIME_WAIT Accumulation and Port Exhaustion
解决办法:
- Parallel connections
Concurrent HTTP requests across multiple TCP connections
并行多TCP连接, - Persistent connections
Reusing TCP connections to eliminate connect/close delays
共有一个TCP长连接,HTTP/1.1 默认为长连接
消除TCP connection延时
delays - Pipelined connections
Concurrent HTTP requests across a shared TCP connection
消除数据传输延时(transfer latencies) -
Multiplexed connections
Interleaving chunks of requests and responses (experimental)- 缓存控制
- 缓存控制
不缓存!
Cache-Control: no-store
Cache-Control: no-cache do-notserve-from-cache-without-revalidation.
Pragma: no-cache
Cache-Control: must-revalidate
转载于:https://blog.51cto.com/xwandrew/2083336