caching - Nginx,关闭特定文件的缓存

标签 caching nginx

location /static {
    alias /home/ubuntu/Documents/zibann/momsite/momsite/static; # your Django project's static files - amend as required
    if ($uri ~* ".*config.js") {
       expires off;
    }

    if ($uri ~* ".*\.(js|css|png|jpg|jpeg|gif|swf|svg)" ) {
       access_log off;
       expires 365d;
       add_header Cache-Control public;
    }

}

希望config.js不会被缓存,但确实如此。
如何从缓存中排除一个文件?

最佳答案

为 config.js 在其他块之上创建一个单独的位置块。

location ~ config\.js {
    alias xyz;
    expires off;
}

location static etc

关于caching - Nginx,关闭特定文件的缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29466494/

相关文章:

nginx - 如何使用 nginx 在同一端口上为多个域提供服务

android - JSON 中的最后一张图片未显示

python - 在 Pylons 中禁用浏览器缓存

angularjs - Office 加载项缓存我的 HTML 文件

django - nginx 无法与 Gunicorn 一起使用外部 IP

nginx - 我的 nginx + fastcgi 配置下载 php 文件而不是执行它们

ssl - Prestashop + NGINX + 让我们加密 : SSL shows as not secure in search bar

java - 运行 GWT 应用程序时出现 Unitcahche 异常

firebase - 如何在 Flutter 中缓存 Firebase 数据?

nginx - 如何在Nginx日志中记录反向代理上游服务器服务请求?