Files
PlaylistShared/PlaylistShared.Pwa/nginx.conf
2026-04-13 14:16:44 +03:00

55 lines
1.9 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Сжатие
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/wasm application/json;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Для Service Worker запрещаем кэширование, чтобы он всегда был свежим
location = /service-worker.js {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
try_files $uri =404;
}
# Для файла манифеста Service Worker assets тоже не кэшируем
location = /service-worker-assets.js {
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
try_files $uri =404;
}
# Основной SPA fallback: все неизвестные пути отдаём через index.html
location / {
try_files $uri $uri/ /index.html?$args;
}
# Кэширование статических ресурсов (css, js, изображения, шрифты)
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Для .wasm файлов правильный MIMEтип и кэширование
location ~* \.wasm$ {
default_type application/wasm;
expires 1y;
add_header Cache-Control "public, immutable";
}
}
}