What is the MIME type of .gz files?
The MIME type (media type) for Gzip archive files with the .gz extension is application/gzip. You may also see application/x-gzip. A gzip file served as a download. Do not confuse it with Content-Encoding: gzip, which compresses a response transparently.
Content-Type header
Content-Type: application/gzip
Server configuration
| Server | Configuration |
|---|---|
Nginx (mime.types or types {}) | application/gzip gz; |
Apache (.htaccess) | AddType application/gzip .gz |
IIS (web.config) | <mimeMap fileExtension=".gz" mimeType="application/gzip" /> |
| Node.js / Express | res.type('gz') or res.setHeader('Content-Type', 'application/gzip') |
| Amazon S3 | Set Content-Type: application/gzip on the object (metadata), or pass --content-type application/gzip to aws s3 cp |
Should .gz files be compressed?
No. Gzip archive files are already compressed internally, so gzip or Brotli would waste CPU and barely reduce — sometimes even increase — the size. Leave application/gzip out of your compression configuration.
Why the MIME type matters
Browsers decide what to do with a response — render, run, play or download — from the Content-Type header, not the file extension. With X-Content-Type-Options: nosniff, a wrong type causes stylesheets and scripts to be blocked outright. For uploads, never trust the type sent by the client; check the file’s content (its magic bytes) on the server.
Frequently asked questions
What is the MIME type for .gz?
application/gzip. Alternatives seen in the wild: application/x-gzip.How do I set the Content-Type for .gz in Nginx?
application/gzip gz; is listed in the types block (usually in /etc/nginx/mime.types) and reload Nginx.