OSS通过在Get请求的Header中添加Accept-Encoding为gzip,对常见网页静态文件(HTML、Javascript、XML、json)内容进行gzip压缩。

前提条件

  • 文件大于或者等于 1KB。
  • Conetnt-Type 必须是 text/cache-manifest、text/xml、text/plain、text/css、application/javascript、application/x-javascript、application/rss+xml、application/json、text/json 中的一个。

API示例

  • 请求示例
    GET /ossutil.txt HTTP/1.1
    Host: agent-test1.oss-cn-qingdao.aliyuncs.com
    User-Agent: curl/7.47.0
    Accept: */*
    Accept-Encoding: gzip
  • 返回示例
    HTTP/1.1 200 OK
    Server: AliyunOSS
    Date: Thu, 23 May 2019 02:03:39 GMT
    Content-Type: text/plain; charset=utf-8
    Transfer-Encoding: chunked
    Connection: keep-alive
    Vary: Accept-Encoding
    x-oss-request-id: 5CE5FF7BFEC931F2900F9F2A
    Last-Modified: Thu, 23 May 2019 02:01:11 GMT
    x-oss-object-type: Normal
    x-oss-hash-crc64ecma: 3161812495027039701
    x-oss-storage-class: Standard
    Content-MD5: XSpWpgD//mzytMaVJCE77w==
    x-oss-server-time: 0
    Content-Encoding: gzip
    [965 bytes data]