chore(cache): 切换为 Nginx 静态资源缓存策略
All checks were successful
CI / build (push) Successful in 2m6s

将图标资源迁移到 src/assets 并通过构建产物 hash 管理缓存,移除 public 目录旧图标引用;新增 Nginx 配置,设置 index.html 协商缓存与 /assets 长缓存策略。

Made-with: Cursor
This commit is contained in:
2026-04-24 16:14:56 +08:00
parent d93b4d178f
commit 6e8acef10f
7 changed files with 41 additions and 5 deletions

32
nginx.conf Normal file
View File

@@ -0,0 +1,32 @@
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;
}
}