# Seven Kingdoms (WASM) — serving rules for IONOS/Apache

# Correct MIME types so the browser streams/compiles the WebAssembly + data.
AddType application/wasm .wasm
AddType application/octet-stream .data

<IfModule mod_headers.c>
  # HTML must not be cached (IONOS default 1h cache would strand updates).
  <FilesMatch "\.html$">
    Header set Cache-Control "no-cache, no-store, must-revalidate"
  </FilesMatch>
  # The big immutable build artifacts: cache hard so a language-switch reload
  # does NOT re-download ~100 MB.
  <FilesMatch "\.(wasm|data|js)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  # ...EXCEPT the service worker: it must update promptly (last match wins),
  # otherwise a cached old sw.js would keep serving stale shell logic.
  <FilesMatch "^sw\.js$">
    Header set Cache-Control "no-cache, no-store, must-revalidate"
  </FilesMatch>
</IfModule>

# Compress wasm/js (data is already binary-packed).
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE application/wasm application/javascript text/javascript text/html
</IfModule>
