【http】 http 头介绍

记录 http 头的用法

https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers

内容控制(Content)

  • Accept-Ranges
    表示该服务器是否支持范围请求

  • Content-Disposition
    指示一个资源应该内联显示在浏览器,还是作为附件下载

    https://www.rfc-editor.org/rfc/rfc1806.txt

  • Content-Range
    表示返回是数据在哪个范围里

    1
    2
    Content-Range: bytes 0-1023/146515
    Content-Length: 1024
  • Content-Type
    标识资源的 media type。在请求中,表示请求体的类型,在响应中,表示返回体的类型

  • Range
    在 GET 请求中使用,表示需要服务端返回指定范围的数据

    1
    Range: bytes=0-50, 100-150

缓存控制(Cache)

  • Cache-Control
    可以在请求和响应中使用,实现缓存机制。

    在 HTTP 请求中可以使用以下标准 Cache-Control 指令
    Cache-Control: max-age=<seconds>
    Cache-Control: max-stale[=<seconds>]
    Cache-Control: min-fresh=<seconds>
    Cache-control: no-cache
    Cache-control: no-store
    Cache-control: no-transform
    Cache-control: only-if-cached

    服务器可以在响应中使用以下标准 Cache-Control 指令
    Cache-control: must-revalidate
    Cache-control: no-cache
    Cache-control: no-store
    Cache-control: no-transform
    Cache-control: public
    Cache-control: private
    Cache-control: proxy-revalidate
    Cache-Control: max-age=<seconds>
    Cache-control: s-maxage=<seconds>

  • Expires

  • Last-Modified

  • Pragma