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/css, text/html, text/plain, application/javascript, application/x-javascript, application/rss+xml, application/json, or text/json.
Usage notes
After the object is compressed in the GZIP format, the Content-Encoding: gzip header will be included in the response headers of API operations such as GetObject and HeadObject. The ETag, Content-Length and Accept-Ranges fields will not be returned.
Examples
Sample requests
GET /example.txt HTTP/1.1 Host: examplebucket.oss-cn-hangzhou.aliyuncs.com Accept: */* Accept-Encoding: gzipSample responses
HTTP/1.1 200 OK Server: AliyunOSS Date: Tue, 19 Nov 2024 08:38:22 GMT Content-Type: text/plain Connection: keep-alive Vary: Accept-Encoding x-oss-request-id: ********** Last-Modified: Tue, 19 Nov 2024 06:04:02 GMT x-oss-object-type: Normal x-oss-hash-crc64ecma: ******************** x-oss-storage-class: Standard x-oss-version-id: *************************************** x-oss-ec: ************ Content-Disposition: attachment x-oss-force-download: true Content-MD5: ****************** x-oss-server-time: 35 Content-Encoding: gzip