我的服务器使用VestaCP运行多个网站。这些网站中的每一个都有不同的公共 html 文件夹和特定的 nginx.conf 文件。(通配符 nginx 包括)
我正在尝试禁用 nginx 中特定文件名的缓存...
我知道如何禁用特定文件的缓存,但我想在文件名为“hello.js”时禁用 nginx.conf 中的缓存(无论它是从哪个站点/位置传递的)。
示例:
https://example.com/hi.js = cached
https://example.com/hello.js = not cached
https://example.com/test/hello.js = not cached
https://example.org/index.js = cached
https://example.org/me/hello.js = not cached
我知道如何在域特定的 snginx.conf 中禁用 1 个特定文件的缓存,但我宁愿有一个规则禁用每个名为“hello.js”的文件的缓存。
server {
listen 443 http2;
server_name example.com;
location /hello.js{
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
expires -1;
}
}
如何禁用所有“hello.js”文件的缓存(也在服务器上托管的其他域上)?
(我问这个问题是因为我与服务工作者一起工作,并且服务工作者 javascript 文件不应该被缓存。如果服务工作者文件被浏览器缓存,那么当缓存名称更改时,新版本永远不会加载。)