How it works
When a client sends anAccept-Encoding: gzip header, WebPublish checks the task’s gzip setting:
- Gzip enabled — the response body is compressed with
zlib.gzipSyncbefore it is sent. If the client instead advertisesAccept-Encoding: deflate,zlib.deflateSyncis used. - Gzip disabled — the response is sent uncompressed, regardless of what the client accepts.
Content-Encoding response header is set to gzip or deflate so the client knows to decompress the body.
Enabling and disabling gzip
Gzip is a per-task setting. It defaults totrue for all task types.
To change it, open the task’s edit dialog:
When to enable gzip
Gzip is beneficial for content that compresses well and is not already compressed at the storage level.| Content type | Recommended setting | Reason |
|---|---|---|
| Static HTML, CSS, JS | Enabled | Text compresses well; reduces transfer size significantly |
| GeoJSON | Enabled | JSON is highly compressible |
| Large JSON or XML files | Enabled | Reduces bandwidth for large structured data |
| PNG raster tiles | Disabled | PNG is already losslessly compressed; re-compressing adds CPU cost with negligible size reduction |
| Video, audio, JPEG images | Disabled | Already compressed; gzip overhead is not worth the marginal gain |
MBTiles vector tiles: special handling
MBTiles files that store vector tiles in PBF format often compress the tile data internally with gzip before writing it to the SQLite database. WebPublish detects this at request time by checking for the gzip magic bytes (0x1f 0x8b) at the start of the tile buffer.
The result depends on whether the stored tile is already compressed and whether the client accepts gzip:
| Stored tile | Client accepts gzip | Task gzip setting | What WebPublish sends |
|---|---|---|---|
| Already gzip-compressed | Yes | Enabled | Passes the compressed tile through unchanged |
| Already gzip-compressed | No | Enabled | Decompresses the tile before sending |
| Not compressed | Yes | Enabled | Compresses the tile before sending |
| Not compressed | No | Disabled | Sends the tile uncompressed |
The gzip passthrough path is the most efficient: if the stored tile is already compressed and the client accepts gzip, no CPU work is done on the tile data at all.
Related pages
MBTiles task
Full reference for the MBTiles tile server task type
File task
Serve individual files with optional gzip compression