【发布时间】:2018-08-07 06:38:19
【问题描述】:
我当前的项目几乎使用以下配置:
root %%COMP_WEB_ROOT;
# COMP Static File serving
location /comp {
alias %%COMP_WEB_ROOT;
try_files $uri$args $uri$args/ /index.html;
add_header 'Cache-Control' 'no-cache, no-store, must-revalidate';
}
# Hide the index file, not exposing that path specifically
location = /index.html {
internal;
}
这样,我将阻止整个应用程序的缓存,这是不可取的,因为我只想阻止 index.html 页面存储缓存。
所以我尝试将add_header 行放在第二个块中,如下所示:
root %%COMP_WEB_ROOT;
# COMP Static File serving
location /comp {
alias %%COMP_WEB_ROOT;
try_files $uri$args $uri$args/ /index.html;
error_page 401 = @error401web;
}
# Hide the index file so that we're not exposing that path specifically
location = /index.html {
internal;
add_header 'Cache-Control' 'no-cache, no-store, must-revalidate';
}
NGINX 能够运行,但 index.html 似乎仍在存储缓存,就好像 add_header 不存在一样。
我还缺少其他命令吗?
【问题讨论】:
标签: caching nginx cache-control