perf(nginx): 静态图/推广资源 Cache-Control 7d,index.html 禁止长期缓存
Made-with: Cursor
This commit is contained in:
@@ -15,24 +15,35 @@ server {
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
expires -1;
|
||||
}
|
||||
|
||||
# web/public 挂载 /var/www/yh-public;单段文件名同 dist 根 URL,优先挂载后回退 dist
|
||||
location ~ ^/([^/]+\.(?:png|jpe?g|gif|ico|svg|webp|webmanifest))$ {
|
||||
root /var/www/yh-public;
|
||||
try_files /$1 @dist_root_public;
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
}
|
||||
location @dist_root_public {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri =404;
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
}
|
||||
|
||||
location ^~ /social/ {
|
||||
alias /var/www/yh-public/social/;
|
||||
add_header Cache-Control "public, max-age=300";
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
}
|
||||
|
||||
location ^~ /promotion/ {
|
||||
try_files $uri =404;
|
||||
add_header Cache-Control "public, max-age=86400";
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, max-age=604800";
|
||||
}
|
||||
|
||||
location = / {
|
||||
|
||||
Reference in New Issue
Block a user