When you send a GET request to Object Storage Service (OSS) to download a static object used in web pages, such as an HTML, JavaScript, XML, or JSON object, you can add the Accept-Encoding header to the GET request and set the value of this header to gzip. This way, the object is compressed in the GZIP format before being downloaded.

Prerequisites

  • The object that you download is equal to or larger than 1 KB in size.
  • The Content-Type header in the GET request is set to one of the following values: text/cache-manifest, text/xml, text/plain, text/css, application/javascript, application/x-javascript, application/rss+xml, application/json, or text/json.

Examples

  • Sample requests
    GET /ossutil.txt HTTP/1.1
    Host: agent-test1.oss-cn-qingdao.aliyuncs.com
    User-Agent: curl/7.47.0
    Accept: */*
    Accept-Encoding: gzip
                        
  • Sample responses
    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: 316181249502703****
    x-oss-storage-class: Standard
    Content-MD5: XSpWpgD//mzytMaVJCE7****
    x-oss-server-time: 0
    Content-Encoding: gzip
    [965 bytes data]