nginx不提供更新的静态文件 [英] nginx not serving updated static files

查看:359
本文介绍了nginx不提供更新的静态文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从apache切换到nginx,遇到奇怪的事情.

Switching from apache to nginx, and encountering something weird.

1)说我的网站文档根目录中有一个文件yo.txt,其中包含"foo".

1) Say I have a file yo.txt in the document root of my site and it contains 'foo'.

curl http://localhost/yo.txt => 'foo'

2)然后我将文件更改为包含"bar"

2) then I alter the file to contain 'bar'

curl http://localhost/yo.txt => 'foo'(仍然!)

如果删除yo.txt,我将得到一个404.如果删除所有文本,则在卷曲该URL时,我将正确地得到一个空文件.

If I remove yo.txt, I get a 404. If I remove all the text, I correctly get an empty file when I curl the url.

修改文件后,我检查了最后修改的HTTP标头,即使文件的内容过时,它也是正确的.

I checked the last modified HTTP header after I modify the file, and it is correct, even though the contents of the file are stale.

在apt-get安装nginx之后,我正在使用nginx的标准配置.

I'm using the standard configuration from nginx after an apt-get install nginx.

给什么?

推荐答案

我正在使用Vagrant.在nginx.conf中将sendfile设置为off可以解决

I'm using Vagrant. Setting sendfile to off in nginx.conf fixed the problem as found here, e.g."

sendfile off;

这篇关于nginx不提供更新的静态文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆