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;
|
listen 8080;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
|
||||||
|
absolute_redirect off;
|
||||||
|
port_in_redirect off;
|
||||||
|
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|
||||||
@@ -11,20 +14,30 @@ server {
|
|||||||
# Support for SPA routing
|
# Support for SPA routing
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
|
add_header Cache-Control "no-cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
# Don't serve index.html for missing assets
|
# Don't serve index.html for missing assets
|
||||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|wasm|json)$ {
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|wasm|json|proto)$ {
|
||||||
try_files $uri =404;
|
|
||||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||||
}
|
access_log off;
|
||||||
|
|
||||||
# Handle manifest.json specifically if needed
|
|
||||||
location = /manifest.json {
|
|
||||||
try_files $uri =404;
|
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 {
|
location /api/v1/auth/status {
|
||||||
return 200 '{"auth_enabled": false, "authenticated": true}';
|
return 200 '{"auth_enabled": false, "authenticated": true}';
|
||||||
add_header Content-Type application/json;
|
add_header Content-Type application/json;
|
||||||
|
|||||||
Reference in New Issue
Block a user