Nginx 禁用缓存:除了 JS 和 CSS 之外的所有文件
要禁止 Nginx 缓存所有扩展名非 js 和 css 的文件,可以在 Nginx 配置文件中添加以下代码:
location ~* \.(?!js|css)[^.]+$ {
add_header Cache-Control 'no-cache, no-store, must-revalidate';
expires 0;
}
这将匹配所有不以 .js 和 .css 为扩展名的文件,并向响应头添加 Cache-Control 和 Expires 标头,以强制客户端不缓存这些文件。
原文地址: https://www.cveoy.top/t/topic/mPbs 著作权归作者所有。请勿转载和采集!