vue-router的history模式要求写成location / { try_files $uri $uri/ /index.html;}vue-cli的pwa模板的文档要求配置一些有关缓存的选项location ~ (index.html|service-worker.js)$ { # ... add_header Last-Modified $date_gmt; add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off;}对nginx并不熟悉,我把这两个都写上的时候,似乎只能生效一个,求指点应该怎么写
1 回答
largeQ
TA贡献2039条经验 获得超7个赞
try_files $uri $uri/ /index.html;写到server块就行
比如
try_files $uri $uri/ /index.html;
location / {
try_files $uri $uri/ /index.html;
}
location ~ (index.html|service-worker.js)$ {
# ...
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
添加回答
举报
0/150
提交
取消