mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 08:11:54 +00:00
have nginx cache static assets
This commit is contained in:
+27
@@ -30,6 +30,9 @@ map $uri $uri_path {
|
||||
default $uri;
|
||||
}
|
||||
|
||||
# Cache configuration
|
||||
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=STATIC:10m inactive=24h max_size=1g;
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
|
||||
@@ -37,6 +40,30 @@ server {
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
# Static file caching for the "static" directory
|
||||
location ~ ^/static/(.*)$ {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
proxy_cache STATIC;
|
||||
proxy_ignore_headers Cache-Control;
|
||||
proxy_cache_valid 200 302 60m;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_cache_lock on;
|
||||
add_header X-Cache-Status $upstream_cache_status;
|
||||
|
||||
# Cache bypass if needed (for development/debugging)
|
||||
proxy_cache_bypass $http_pragma $http_authorization;
|
||||
|
||||
# No TTL as requested (browser will check each time)
|
||||
expires -1;
|
||||
add_header Cache-Control "no-cache";
|
||||
|
||||
# Standard proxy headers
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# Main location
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
|
||||
Reference in New Issue
Block a user