From c463c824100a07055fe8c83daeb822ed20683913 Mon Sep 17 00:00:00 2001 From: mstfyldz Date: Mon, 4 May 2026 22:37:33 +0300 Subject: [PATCH] perf: add nginx.template.conf with aggressive caching for Nixpacks --- nginx.template.conf | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 nginx.template.conf diff --git a/nginx.template.conf b/nginx.template.conf new file mode 100644 index 0000000..ecbe88e --- /dev/null +++ b/nginx.template.conf @@ -0,0 +1,52 @@ +server { + listen ${PORT}; + server_name _; + root /app; + index index.php index.html index.htm; + + # 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 font/woff2; + + # Browser Caching + location ~* \.(jpg|jpeg|png|gif|webp|svg|ico|cur|gz|svgz|mp4|ogg|ogv|webm|htc)$ { + expires 1y; + access_log off; + add_header Cache-Control "public, max-age=31536000, immutable"; + } + + location ~* \.(css|js)$ { + expires 1M; + access_log off; + add_header Cache-Control "public, max-age=2592000, immutable"; + } + + location ~* \.(woff|woff2|ttf|otf|eot)$ { + expires 1y; + access_log off; + add_header Cache-Control "public, max-age=31536000, immutable"; + } + + # HTML - Short cache + location ~* \.(html|htm)$ { + expires 1h; + add_header Cache-Control "public, max-age=3600, must-revalidate"; + } + + # PHP Handling + location ~ \.php$ { + fastcgi_pass 127.0.0.1:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + location / { + try_files $uri $uri/ /index.html /index.php?$query_string; + } + + error_page 404 /404.html; +}