【问题标题】:nginx always sends stale index.htmlnginx 总是发送陈旧的 index.html
【发布时间】:2016-05-08 18:47:53
【问题描述】:

我正在使用 nginx 作为烧瓶应用程序的反向代理 Web 服务器。这是我的配置文件:

server {
    access_log /var/log/nginx.log main;
    error_log /var/log/nginx_err.log warn;

    location / {
        proxy_cache_revalidate on;
        proxy_pass http://localhost:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

当我转到服务器的根目录时,例如www.myserver.com(nginx 正在监听 80 端口),chrome 总是使用缓存来获取 index.html 文件。查看 nginx 日志,GET / 根本没有记录,我的 Web 应用程序 (python-flask) 甚至没有收到请求。

当转到 www.myserver.com/#/ 时,请求确实通过了。

知道是什么导致了这个问题以及如何防止这种情况发生吗?

【问题讨论】:

    标签: python nginx flask


    【解决方案1】:

    你可能想试试这个:

    如果 proxy_buffering 设置为 off,NGINX 将不会缓存响应。默认开启。

    来源:https://www.nginx.com/blog/nginx-caching-guide/

    【讨论】:

    • 我已将proxy_buffering off; 添加到location / 部分,但我仍然得到相同的行为。还有什么建议吗?谢谢
    • 这将强制使用“Cache-Control: no-cache”标头,这意味着它将禁用浏览器缓存:expires -1;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-20
    • 2013-01-18
    • 2020-09-27
    • 2015-05-20
    • 2013-07-30
    • 1970-01-01
    相关资源
    最近更新 更多