Skip to content

v0.36.0

Choose a tag to compare

@tannevaled tannevaled released this 15 Nov 14:18
· 3 commits to main since this release
0dbc8c1

wasmcache: cached responses carry only the headers the cache can vouch for (#53, closes #50).

Before: when a file was stored, the response kept whatever headers it came with. A file copied from an old build's cache (v0.33.0) kept the old entry's headers, which were never checked: only the bytes were hash-checked against the manifest.

Now: every response wasmcache-sw.js stores is built the same way, whether it comes from a cache hit, a network fetch, a hash-checked network fallback, or a copy from the old build:

  • Content-Type comes from the file extension: wasm, js/mjs, json, html (utf-8), css, otherwise application/octet-stream.
  • Security headers the host sent are kept, from a fixed list: Content-Security-Policy, Content-Security-Policy-Report-Only, X-Frame-Options, Permissions-Policy, Referrer-Policy, Cross-Origin-Opener-Policy, Cross-Origin-Embedder-Policy, Cross-Origin-Resource-Policy and X-Content-Type-Options. They are taken from the network response at store time, or from the old entry when copying, and only after the bytes pass the hash check.
  • Nothing else carries over.

The security list matters for hosts that send these as HTTP headers. A frame-ancestors CSP (which a <meta> tag cannot set) or COOP/COEP (which wasm threads need for crossOriginIsolated) must not be lost when a page is served from the cache.

Tests: the test kit plants an old entry with matching bytes, a wrong Content-Type and an extra x-planted header. It is reused without a download, with the extension's Content-Type and without x-planted. A CSP and a COOP header on the page survive a cache hit, a copy and a network store. Each check was proven by mutation: an empty list drops the CSP, and allowing every header lets x-planted through.