diff --git a/nginx.conf b/nginx.conf index d610cd1..6797afa 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,13 +1,13 @@ server { listen 80; - server_name localhost; + server_name _; root /usr/share/nginx/html; index index.html; - # Disable caching for all responses - add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; - add_header Pragma "no-cache"; - expires off; + # Disable caching for all responses during debugging + add_header Cache-Control "no-cache, no-store, must-revalidate" always; + add_header Pragma "no-cache" always; + add_header Expires "0" always; # Favicon location = /favicon.ico { @@ -16,14 +16,14 @@ server { log_not_found off; } - location = style2.css { - try_files /style2.css =204; + # Serve shared JS and CSS directories at root + location /js/ { + try_files $uri =404; } - location = chatv3.js { - try_files /chatv3.js =204; + location /css/ { + try_files $uri =404; } - # Custom 404 page error_page 404 /404.html; location = /404.html { @@ -77,9 +77,20 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + # Cache static assets with content hash - minimal caching + location ~* \.(js|css)$ { + expires 1s; # 1 second for rapid iteration + add_header Cache-Control "public, max-age=1, must-revalidate" always; + } + # Cache images and icons - short caching + location ~* \.(ico|png|svg|jpg|jpeg|gif|webp)$ { + expires 5s; # 5 seconds, adjust as needed + add_header Cache-Control "public, max-age=5, must-revalidate" always; + } # Gzip compression for better performance gzip on; gzip_vary on; + gzip_min_length 1024; gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json; }