<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-l
  RewriteRule . /index.html [L]
</IfModule>

# Caching: without explicit headers browsers fall back to heuristic
# caching and keep serving assets of an earlier release.
<IfModule mod_headers.c>
  # The HTML entry points are unhashed and reference the content-hashed
  # bundles of the *current* release, so they must never be reused from
  # the cache without asking — a stale index.html would point at files
  # the new release no longer contains.
  <FilesMatch "\.html$">
    Header set Cache-Control "no-cache, must-revalidate"
  </FilesMatch>

  # Content-hashed bundles are immutable: any change gives them a new
  # name, so they can be cached indefinitely.
  <FilesMatch "\.[0-9a-f]{8,}\.(bundle|chunk)\.js$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
</IfModule>
