use*_*547 7 nginx cache-control http-headers
我有以下配置(对于 Angular 应用程序):
location / {
try_files $uri /index.html;
add_header "Cache-Control" "no-cache" ;
}
Run Code Online (Sandbox Code Playgroud)
现在我想仅为index.html,但不为任何其他文件添加该标头。怎么做?
\n\n\n使用 \xe2\x80\x9c=\xe2\x80\x9d 修饰符可以定义 URI\n 和位置的精确匹配。如果找到完全匹配,则搜索终止。
\n
所以你可以使用这个配置:
\n\nlocation =/index.html {\n add_header "Cache-Control" "no-cache" ;\n}\nlocation / {\n rewrite ^(.*) /index.html break;\n\n}\nRun Code Online (Sandbox Code Playgroud)\n\n您可以在以下位置找到更多信息
\n\n\n\n\n| 归档时间: |
|
| 查看次数: |
5513 次 |
| 最近记录: |