web deploy

This commit is contained in:
2025-11-04 20:32:40 +01:00
parent 2cf1fb648c
commit f7839d1dfb
5 changed files with 153 additions and 16 deletions
+53
View File
@@ -0,0 +1,53 @@
# Flutter Web on Apache: SPA routing, caching, compression, and correct MIME types
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
# Serve existing files/directories directly
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Fallback all other requests to index.html (client-side routing)
RewriteRule ^ index.html [L]
</IfModule>
# Correct MIME types (important for CanvasKit/WebAssembly and fonts)
AddType application/wasm wasm
AddType font/woff2 woff2
AddType application/javascript js
AddType text/css css
# Caching policy
<IfModule mod_headers.c>
# Long cache for static assets (Flutter uses hashed filenames)
<FilesMatch "\.(js|css|png|jpg|jpeg|gif|svg|ico|woff|woff2|ttf|wasm)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
# Service configs/JSON can be cached briefly
<FilesMatch "\.(json)$">
Header set Cache-Control "public, max-age=3600"
</FilesMatch>
# Never cache the HTML entry point
<FilesMatch "^index\.html$">
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
</FilesMatch>
# Minimal hardening
Header always set X-Content-Type-Options "nosniff"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
# Compression (enable if modules are available)
<IfModule mod_brotli.c>
AddOutputFilterByType BROTLI_COMPRESS \
text/html text/plain text/css application/javascript application/json application/wasm image/svg+xml
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE \
text/html text/plain text/css application/javascript application/json application/wasm image/svg+xml
</IfModule>