perf(web): add gzip compression + cache-control headers for static assets

- Add CompressionLayer to web router for gzip compression of JS/CSS/JSON/SVG
- Add Cache-Control header (7 days + stale-while-revalidate) via SetResponseHeaderLayer
- Add 'set-header' feature to tower-http dependency
- Result: 67-85% reduction in transfer size for all static assets
This commit is contained in:
Diocrafts
2026-02-17 19:29:42 +01:00
parent 828da554c6
commit f661282962
2 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ tokio-stream = { version = "0.1.18", features = ["fs"] }
bytes = "1.11.1"
tempfile = "3.25.0"
tower = "0.5.3"
tower-http = { version = "0.6.8", features = ["fs", "compression-gzip", "trace", "cors", "add-extension", "request-id"] }
tower-http = { version = "0.6.8", features = ["fs", "compression-gzip", "trace", "cors", "add-extension", "request-id", "set-header"] }
flate2 = "1.1.9"
zip = "=6.0.0"
tracing = "0.1.44"