# ============================================================
# Croc Watch User Guide — Production Configuration
# Shared web hosting (Apache)
# ============================================================

# ── Security: Prevent directory listing ──
Options -Indexes

# ── Security: Protect hidden files ──
<FilesMatch "^\.">
  Require all denied
</FilesMatch>

# ── Enable compression ──
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
  AddOutputFilterByType DEFLATE application/javascript application/x-javascript application/json
  AddOutputFilterByType DEFLATE application/xml image/svg+xml
  AddOutputFilterByType DEFLATE font/woff2 font/woff
</IfModule>

# ── Cache control for static assets ──
<IfModule mod_expires.c>
  ExpiresActive On

  # Default: 1 week
  ExpiresDefault "access plus 1 week"

  # Images: 1 month
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/webp "access plus 1 month"
  ExpiresByType image/svg+xml "access plus 1 month"

  # Fonts: 1 year (versioned via filename)
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType font/woff "access plus 1 year"

  # CSS & JS: 1 month
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"

  # HTML: 1 day
  ExpiresByType text/html "access plus 1 day"
</IfModule>

# ── Cache control via headers (fallback) ──
<IfModule mod_headers.c>
  # 1 month for images, fonts, CSS, JS
  <FilesMatch "\.(jpg|jpeg|png|gif|webp|svg|woff2|woff|css|js)$">
    Header set Cache-Control "public, max-age=2592000, immutable"
  </FilesMatch>

  # 1 day for HTML
  <FilesMatch "\.(html)$">
    Header set Cache-Control "public, max-age=86400"
  </FilesMatch>
</IfModule>

# ── Character set ──
AddDefaultCharset UTF-8
AddCharset UTF-8 .html .css .js

# ── Rewrites (if needed) ──
<IfModule mod_rewrite.c>
  RewriteEngine On

  # Force HTTPS (uncomment on production):
  # RewriteCond %{HTTPS} off
  # RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # Remove trailing slash:
  # RewriteRule ^(.+)/$ /$1 [L,R=301]
</IfModule>
