一些术语

  • Web页:由一些对象组成
  • 基本的HTML文件
  • 通过URL对每个对象进行引用
  • URL:协议名 用户:口令 主机名 端口号 路径名

    HTTP概况

  • HTTP:超文本传输协议

HTTP Message Format

HTTP规范包含了HTTP message的格式。有两种类型的HTTP message: request message和response message。这些message都为ASCII文本格式。

HTTP Request Message

image.png
上面的图片中就是一个request message,有五行,每行由一个回车和换行符结束。最后一行有两个回车换行符。
解释图中例子
第一行称为request line。后四行称为header lines。
request line有三个字段:方法字段,URL字段,HTTP版本字段
Connection: close:非持续连接
User-agent: Mozilla/5.0:用户代理,也就是发送request的浏览器类型。
Accept-language: fr:表示用户倾向于收到法语版本的对象(文字、图片等)。

HTTP连接

持久HTTP:non-persistent connections:一对请求/响应报文只通过一条TCP连接传送。
非持久HTTP:persistent connections:所有请求和响应都通过同一条TCP连接传送。

Cookies

A cookie is a code used by a server, carried on a client’s HTTP request, to access information the server had earlier stored about an earlier interaction with this Web browser. [Think about the distinction between a browser and a person.]

Web caches

服务端给客户端给多传输一些数据,这样下一下请求的时候,会有一定概率要请求的信息已经在本地,来缩短响应时间。说白了就是缓存。

The Conditional GET

尽管web cache技术能带来一些优点,但也会带来一个新的问题:web cache存储空间中存储的内容很可能是过时的,也就是说,该内容的来源服务器中已经有了更新的版本。

为了解决这个问题,HTTP就有了conditional GET这个机制。

满足以下两个条件的HTTP request message可以称为conditional GET message:

  1. request message使用GET方法。
  2. request message包含了If-Modified-Since首部行。

    HTTP/2

    HTTP/2:[RFC 7540, 2015] increased flexibility at server in sending objects to client:
  • methods, status codes, most header fields unchanged from HTTP 1.1
  • transmission order of requested objects based on client-specified object priority (not necessarily FCFS)
  • push unrequested objects to client
  • divide objects into frames, schedule frames to mitigate HOL blocking

checkout

  1. What do we mean when we say “HTTP is stateless”? In answering this question, assume that cookies are not used.

An HTTP server does not remember anything about what happened during earlier steps in interacting with this HTTP client.
(server maintains_ no _information about past client requests)

  1. What is the purpose of the conditional HTTP GET request message?

To allow a server to only send the requested object to the client if this object has changed since the server last sent this object to the client.

  1. Which of the following are advantages of using a web cache? Select one or more answers.
  • Caching uses less bandwidth coming into an institutional network where the client is located, if the cache is also located in that institutional network.
  • Caching generally provides for a faster page load time at the client, if the web cache is in the client’s institutional network, because the page is loaded from the nearby cache rather than from the distant server.
  1. What is the purpose of the _If-Modified-Since _field in a HTTP GET request message?
  • To indicate to the server that the client has cached this object from a previous GET, and the time it was cached.