.gz MIME type
Gzip filearchives
application/gzipA gzip-compressed file, registered by RFC 6713.
| MIME type | application/gzip |
|---|---|
| Extensions | .gz, .gzip |
| Also seen as | application/x-gzip |
| Content-Type | application/gzip |
| Compress in transit? | No — already compressed |
| File signature | 1F 8B |
Good to know
- Serving a
.gzdownload asapplication/gzipis different fromContent-Encoding: gzip, which tells the browser to decompress a response transparently. Mixing them up makes browsers save already-decompressed files with a.gzname, or the reverse. .tar.gzand.tgzfiles are tar archives compressed with gzip and use this type.
Useful here: Content-Encoding header
Serve .gz files with the right type
The response header to send:
Content-Type: application/gzip
Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:
nginx (inside the types block in mime.types)
application/gzip gz gzip;
Apache (.htaccess or server config)
AddType application/gzip .gz .gzip
Express
res.set("Content-Type", "application/gzip");Python
import mimetypes
mimetypes.add_type("application/gzip", ".gz")
mimetypes.add_type("application/gzip", ".gzip")HTML file input
<input type="file" accept=".gz,.gzip,application/gzip">
Check it
See what a server sends for a file, and what type a local file really is by its contents:
curl -sI https://example.com/file.gz | grep -i '^content-type:' file --mime-type file.gz
Frequently asked questions
What is the MIME type for .gz files?
application/gzip. You may also see application/x-gzip, but application/gzip is the one to send. The same type covers .gzip.
What Content-Type header should a .gz file be served with?
Content-Type: application/gzip. It's already compressed, so servers shouldn't gzip it.
How can I tell if a file is really a .gz?
Check its bytes rather than the extension: GZ files start with 1F 8B. On the command line, file --mime-type name.gz does this for you.
Related types
Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options