全部产品
Search
文档中心

OSS的GZIP如何使用?

更新时间: 2019-05-23

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示例

请求示例:

  1. GET /ossutil.txt HTTP/1.1
  2. Host: agent-test1.oss-cn-qingdao.aliyuncs.com
  3. User-Agent: curl/7.47.0
  4. Accept: */*
  5. Accept-Encoding: gzip

返回示例:

  1. HTTP/1.1 200 OK
  2. Server: AliyunOSS
  3. Date: Thu, 23 May 2019 02:03:39 GMT
  4. Content-Type: text/plain; charset=utf-8
  5. Transfer-Encoding: chunked
  6. Connection: keep-alive
  7. Vary: Accept-Encoding
  8. x-oss-request-id: 5CE5FF7BFEC931F2900F9F2A
  9. Last-Modified: Thu, 23 May 2019 02:01:11 GMT
  10. x-oss-object-type: Normal
  11. x-oss-hash-crc64ecma: 3161812495027039701
  12. x-oss-storage-class: Standard
  13. Content-MD5: XSpWpgD//mzytMaVJCE77w==
  14. x-oss-server-time: 0
  15. Content-Encoding: gzip
  16. [965 bytes data]