带有 Virtualbox 的 Nginx 和 Gunicorn 将旧版本的 Django 静态文件 padded/cropped 提供给新的文件大小,sendfile off 不起作用

Nginx and Gunicorn with Virtualbox serves old verison of Django static files padded/cropped to new file size, sendfile off doesn't work

我的问题与 here and here 中描述的问题相同,但在 nginx.conf 中设置 sendfile off; 没有帮助。

我 运行正在使用 Virtualbox (Ubuntu 16.04) 和 Nginx、Gunicorn 和 Django 的 Vagrant。我使用此设置进行开发,因此我想避免每次更改文件时都必须调用 collectstatic。因此,Nginx 将所有请求路由到 Gunicorn(甚至是“/static/”),Gunicorn 使用这种方法提供静态文件:

if settings.DEBUG:
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns
    urlpatterns += staticfiles_urlpatterns()

这可行,但如果我更改静态文件中的某些内容,则内容不会更新,只会更新文件大小。我已经尝试在 nginx.conf 中设置 sendfile off;,也在我的 Gunicorn 配置中设置。尽管如此,问题仍然存在。有什么办法可以缩小导致此问题的可能原因的范围吗?

所有 Django 文件都在与 Windows 10 主机系统共享的文件夹中,但如果我使用 vagrant ssh 并检查文件,它们已正确更新。

编辑: 如果我只 运行 Gunicorn 没有 Nginx,问题仍然存在,所以这似乎是一个 Gunicorn/Django 问题。

想通了。

我还需要 运行 带有 --no-sendfile 标志的 Gunicorn。我之前尝试在我的 ini 文件中设置它 (no_sendfile = True),但没有用。但是,在主管中将 --no-sendfile 添加到我的 Gunicorn 运行 命令中有效!