application/gzip MIME Type — Gzip Compression & HTTP Encoding
GNU zip compression format. A single-file compression format using the DEFLATE algorithm. Often used with tar for compressing multiple files (tar.gz / tgz). Also the compression encoding used in HTTP (Content-Encoding: gzip).
Used For
- Server log archives
- Database backup files
- Software tarballs
- Compressed static asset delivery
HTTP Header Example
HTTP/1.1 200 OK
Content-Type: application/gzip
Content-Disposition: attachment; filename="logs.tar.gz"
[binary gzip data]Code Examples
// Serve a .tar.gz file
app.get('/logs.tar.gz', (req, res) => {
res
.set('Content-Type', 'application/gzip')
.set('Content-Disposition', 'attachment; filename="logs.tar.gz"')
.sendFile('/var/log/archive.tar.gz')
})
// Note: HTTP response compression (Content-Encoding: gzip) is different:
// Use compression middleware for that:
import compression from 'compression'
app.use(compression()) // compresses responses, not filesRelated MIME Types
Frequently Asked Questions
What is the application/gzip MIME type?
GNU zip compression format. A single-file compression format using the DEFLATE algorithm. Often used with tar for compressing multiple files (tar.gz / tgz). Also the compression encoding used in HTTP (Content-Encoding: gzip).
When should I set Content-Type: application/gzip?
Set Content-Type: application/gzip on HTTP responses that contain Gzip Archive data. Server log archives.
What file extensions use application/gzip?
Files with application/gzip content typically use these extensions: .gz, .tgz, .tar.gz.
What happens if I serve this with the wrong Content-Type?
Browsers use the Content-Type header to decide how to handle the response. Serving application/gzip content with an incorrect MIME type can cause browsers to display it incorrectly, refuse to execute it (scripts), or prompt an unintended download. Modern browsers respect X-Content-Type-Options: nosniff and will not attempt to auto-detect the type.
