# Vector89 — PWA Cache Strategy
# Forces fresh HTML/JS/CSS on every load, long-cache for static assets.
# Required for iOS PWA "Add to Home Screen" to auto-update.
# v: 20260430b

<IfModule mod_headers.c>
  # App shell: NEVER cache — always fetch fresh
  <FilesMatch "\.(html|js|css|webmanifest|json)$">
    Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
    Header set Pragma "no-cache"
    Header set Expires "0"
  </FilesMatch>

  # Service worker: never cache + allow root scope
  <FilesMatch "^sw\.js$">
    Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
    Header set Pragma "no-cache"
    Header set Expires "0"
    Header set Service-Worker-Allowed "/"
  </FilesMatch>

  # Static assets: long cache (filenames are immutable here)
  <FilesMatch "\.(png|jpg|jpeg|gif|webp|svg|ico|woff|woff2|ttf|eot)$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType text/html              "access plus 0 seconds"
  ExpiresByType application/javascript "access plus 0 seconds"
  ExpiresByType text/javascript        "access plus 0 seconds"
  ExpiresByType text/css               "access plus 0 seconds"
  ExpiresByType application/json       "access plus 0 seconds"
  ExpiresByType application/manifest+json "access plus 0 seconds"
  ExpiresByType image/png              "access plus 1 year"
  ExpiresByType image/jpeg             "access plus 1 year"
  ExpiresByType image/webp             "access plus 1 year"
  ExpiresByType image/svg+xml          "access plus 1 year"
  ExpiresByType image/x-icon           "access plus 1 year"
  ExpiresByType font/woff              "access plus 1 year"
  ExpiresByType font/woff2             "access plus 1 year"
</IfModule>
