# Apache configuration for the Tux Racer web build (copied to web/.htaccess
# by build_web.sh).  Other servers: see WEB_README.md.

# Correct types: browsers only stream-compile WebAssembly served as
# application/wasm (otherwise it still works, just slower to start).
AddType application/wasm .wasm
AddType application/octet-stream .data

# Compress on the fly (the 11 MB data file shrinks by ~40%)
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html application/javascript text/javascript application/wasm application/octet-stream
</IfModule>

<IfModule mod_headers.c>
  # index.js/.wasm/.data are requested with ?v=<build hash>: cache forever
  <FilesMatch "\.(js|wasm|data)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
  # The page itself must be revalidated so players get new builds
  <FilesMatch "\.html$">
    Header set Cache-Control "no-cache"
  </FilesMatch>
</IfModule>
