典型的 HTTP 会话-响应示例(请求资源不存在的网页响应)

发布时间 2023-11-10 09:57:24作者: 安知竹墨
 1 HTTP/1.1 404 Not Found
 2 Content-Type: text/html; charset=utf-8
 3 Content-Length: 38217
 4 Connection: keep-alive
 5 Cache-Control: no-cache, no-store, must-revalidate, max-age=0
 6 Content-Language: en-US
 7 Date: Thu, 06 Dec 2018 17:35:13 GMT
 8 Expires: Thu, 06 Dec 2018 17:35:13 GMT
 9 Server: meinheld/0.6.1
10 Strict-Transport-Security: max-age=63072000
11 X-Content-Type-Options: nosniff
12 X-Frame-Options: DENY
13 X-XSS-Protection: 1; mode=block
14 Vary: Accept-Encoding,Cookie
15 X-Cache: Error from cloudfront
16 <!DOCTYPE html>… (包含一个站点自定义 404 页面,帮助用户找到丢失的资源)

这段代码是HTTP响应头,用于告知客户端请求的资源未找到。以下是对每个字段的解释:

  • HTTP/1.1 404 Not Found: 表示这是一个HTTP 1.1协议的响应,状态码为404,表示请求的资源未找到。
  • Content-Type: text/html; charset=utf-8: 表示响应的内容类型为HTML文本,字符集为UTF-8。
  • Content-Length: 38217: 表示响应内容的长度为38217字节。
  • Connection: keep-alive: 表示使用持久连接来保持与客户端的连接。
  • Cache-Control: no-cache, no-store, must-revalidate, max-age=0: 表示不允许缓存响应内容,不允许将响应内容存储在客户端,必须重新验证响应内容,并且最大缓存时间为0秒。
  • Content-Language: en-US: 表示响应内容的语言为英语(美国)。
  • Date: Thu, 06 Dec 2018 17:35:13 GMT: 表示响应生成的时间。
  • Expires: Thu, 06 Dec 2018 17:35:13 GMT: 表示响应过期的时间。
  • Server: meinheld/0.6.1: 表示服务器软件的名称和版本号。
  • Strict-Transport-Security: max-age=63072000: 启用了严格传输安全策略,最大生存时间为63072000秒。
  • X-Content-Type-Options: nosniff: 禁止浏览器根据文件扩展名推断响应内容的类型。
  • X-Frame-Options: DENY: 禁止在iframe中显示页面。
  • X-XSS-Protection: 1; mode=block: 启用了跨站脚本攻击保护,模式为阻止。
  • Vary: Accept-Encoding,Cookie: 表示响应内容可能因客户端请求的不同而变化,特别是关于编码和cookie的部分。
  • X-Cache: Error from cloudfront: 表示响应来自CloudFront的错误信息。