Precompressed Assets
Webstir precompresses HTML, CSS, and JS assets at publish as sibling files:
.br: Brotli (quality 11)
Artifacts live next to the emitted file in dist/frontend/pages/<page>/.
Why
- Smaller transfer size and faster TTFB without on-the-fly compression.
- Deterministic outputs at publish; better CDN cacheability.
How to Serve
- If client supports Brotli, serve
.brfiles; otherwise serve the plain file. - Set headers when serving precompressed variants:
Content-Encoding: brContent-Typeappropriate to the asset (e.g.,text/html; charset=utf-8,text/css; charset=utf-8,application/javascript)Vary: Accept-Encoding
Example rules (generic)
- If request is for
index.<hash>.<ext>and client accepts Brotli (Accept-Encoding: br), serveindex.<hash>.<ext>.brwithContent-Encoding: br. - Else serve
index.<hash>.<ext>withoutContent-Encoding.
CDN Guidance
- Enable caching for all three variants.
- Ensure cache key varies by
Accept-Encodingor by the file variant path. - Avoid edge/on-demand compression for these files; it adds latency and can defeat deterministic caching.
Notes
.html,.css, and.jsare precompressed. Images, fonts, and videos are already compressed and should not be double-compressed.- Brotli is supported by 96% of browsers (all modern browsers since 2016-2017).