AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 786509
Accepted
thaweatherman
thaweatherman
Asked: 2016-06-28 04:59:01 +0800 CST2016-06-28 04:59:01 +0800 CST 2016-06-28 04:59:01 +0800 CST

页面未缓存

  • 772

我有一个使用flask+gunicorn在nginx后面运行的简单网络应用程序,并且在某个地方正在缓存页面的陈旧版本。我的 nginx 配置在代理通行证add_header Cache-Control no-cache;的proxy_buffering off;位置。我做了一些搜索,发现 gunicorn 本身并没有缓存任何东西。我的应用程序也没有缓存任何东西,或者至少我没有将它写入。

server { listen 80; server_name mywebsite.com; location / { add_header Cache-Control no-cache; proxy_pass http://127.0.0.1:6789; proxy_set_header Host $host; proxy_buffering off; } }

这就是我正在使用的 nginx 配置,gunicorn 是使用它启动的,gunicorn -b 127.0.0.1:6789 -w 5 app:app并且没有为它设置任何特殊配置。

任何诊断问题的帮助都会很棒。谢谢!

编辑:这是来自返回陈旧页面的请求的响应标头。

Age: 0 Cache-Control: no-cache Connection: Keep-Alive Content-Encoding: gzip Content-Type: text/html; charset=utf-8 Date: Mon, 27 Jun 2016 14:27:29 GMT Server: nginx/1.8.0 Transfer-Encoding: chunked

nginx gunicorn flask
  • 2 2 个回答
  • 291 Views

2 个回答

  • Voted
  1. Kleggas
    2016-08-21T10:33:56+08:002016-08-21T10:33:56+08:00

    发送文件之类的静态内容?

    “返回发送文件('mypage.html')”?

    默认情况下,在烧瓶中为我缓存的那种单线器。

    解决方案是:app.config.update(SEND_FILE_MAX_AGE_DEFAULT=0)

    我有一个设置,我只在烧瓶中反馈 html 页面(它们包含角度,所以我不在烧瓶中做任何代码。Gunicorn + nginx 用于托管它,nginx 用于非 html 静态(js、css、字体图像等) . 设置该选项后没有缓存,所以不太可能是你的 gunicorn 或 nginx (但谁知道,我不是他们的专家,也许你有其他版本,而不是我,他们缓存的地方)。所以可能是你的烧瓶,取决于你用它做什么。我管理着 4 个 gunicorn 工人。

    • 0
  2. Best Answer
    thaweatherman
    2016-07-15T05:17:12+08:002016-07-15T05:17:12+08:00

    我得出的结论是,由于 gunicorn 创建了工作线程,因此一个或多个没有工作价格更新线程并陷入陈旧的结果。我现在只用一名工人运行 gunicorn,这似乎违背了使用它的目的,但无论如何。

    • -1

相关问题

  • Gzip 与反向代理缓存

  • nginx 作为代理的行为

  • Nginx 学习资源 [关闭]

  • 提供 70,000 个静态文件 (jpg) 的最佳方式?

  • 在 Apache、LightTPD 和 Nginx Web 服务器上提供 PHP 5.x 应用程序的现状?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve