将图标资源迁移到 src/assets 并通过构建产物 hash 管理缓存,移除 public 目录旧图标引用;新增 Nginx 配置,设置 index.html 协商缓存与 /assets 长缓存策略。 Made-with: Cursor
This commit is contained in:
32
nginx.conf
Normal file
32
nginx.conf
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user