feat(nginx): enhance demo configuration with caching headers, gzip compression, and improved asset handling
This commit is contained in:
@@ -2,6 +2,9 @@ server {
|
||||
listen 8080;
|
||||
server_name localhost;
|
||||
|
||||
absolute_redirect off;
|
||||
port_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
@@ -11,20 +14,30 @@ server {
|
||||
# Support for SPA routing
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# Don't serve index.html for missing assets
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|wasm|json)$ {
|
||||
try_files $uri =404;
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|wasm|json|proto)$ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
|
||||
# Handle manifest.json specifically if needed
|
||||
location = /manifest.json {
|
||||
access_log off;
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# Mock API responses for demo mode
|
||||
# Handle manifest.json and service-worker.js specifically
|
||||
location ~* (manifest\.json|service-worker\.js) {
|
||||
add_header Cache-Control "no-cache";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# Gzip compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
||||
|
||||
# Mock responses for demo mode with the power of NGINX!
|
||||
location /api/v1/auth/status {
|
||||
return 200 '{"auth_enabled": false, "authenticated": true}';
|
||||
add_header Content-Type application/json;
|
||||
|
||||
Reference in New Issue
Block a user