Pre-compress .wasm, .data and .js build files with Brotli at build time, serve them with Content-Encoding: br and the correct Content-Type, and set long, immutable cache headers on hashed filenames while keeping the HTML page uncached.
At a glance
| Fact | Value | Source |
|---|---|---|
| Brotli typically beats gzip on WASM/data files | smaller output | |
| Unity WebGL build compression setting | Brotli or gzip | docs.unity3d.com |
| Godot web export decompression setting | matches server encoding | docs.godotengine.org |
Compress the build output once at build time rather than on every request, then tell the server and the browser how to handle it. For Unity, set the WebGL compression format to Brotli in Player Settings before building; Unity writes .br files alongside the .wasm, .data and framework .js files. For Godot, export for web and make sure the export’s compression setting matches what your server will serve – Godot’s loader expects the encoding it was told to expect. See the Unity WebGL manual and Godot’s web export docs.
If you publish across multiple platforms, Playgama Bridge adapts one HTML5 build to 25+ platforms.
On the server, serve each .br file with Content-Encoding: br and the correct underlying Content-Type (application/wasm, application/octet-stream, application/javascript). Most static hosts and CDNs do this automatically if they see a .br extension or if you enable Brotli in their settings; check your host’s docs since behaviour varies.
For caching: give hashed, versioned filenames (the ones your build tool already generates) a long Cache-Control: public, immutable header, since the filename changes whenever content changes. Keep the entry HTML page itself uncached or short-cached so players always get the latest reference to the current build hash. Test with browser devtools network tab: confirm Content-Encoding: br appears and file sizes match the compressed output, not the raw one.
Sources
Related questions
Should I compress with Brotli or gzip for WebGL builds?
Brotli generally compresses .wasm and .data files smaller than gzip; use it if your host supports serving .br files with correct headers.
Why is my WebGL build not loading after enabling Brotli?
The server is likely serving the .br file without Content-Encoding: br, or the engine’s loader expects a different encoding than what the server sends – check both sides match.
Last updated: 24 September 2026