Files
chat-one-web/nginx.conf
alboped 6e8acef10f
All checks were successful
CI / build (push) Successful in 2m6s
chore(cache): 切换为 Nginx 静态资源缓存策略
将图标资源迁移到 src/assets 并通过构建产物 hash 管理缓存,移除 public 目录旧图标引用;新增 Nginx 配置,设置 index.html 协商缓存与 /assets 长缓存策略。

Made-with: Cursor
2026-04-24 16:14:56 +08:00

33 lines
853 B
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.
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Vite build 产物:文件名带 hash可长期缓存
location /assets/ {
expires 1y;
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri =404;
}
# 单独图标按中等缓存(如果后续也迁到 /assets可删除
location ~* ^/(favicon\.ico|favicon\.png|apple-touch-icon\.png)$ {
expires 7d;
add_header Cache-Control "public, max-age=604800";
try_files $uri =404;
}
# 入口 HTML 每次协商缓存,确保能拿到最新资源清单
location = /index.html {
add_header Cache-Control "no-cache";
try_files $uri =404;
}
# SPA 路由回退
location / {
try_files $uri $uri/ /index.html;
}
}