如何清除nginx的缓存? [英] How to clear the cache of nginx?

查看:137
本文介绍了如何清除nginx的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用nginx作为前端服务器,我修改了CSS文件,但是nginx仍在使用旧的文件.

I use nginx to as the front server, I have modified the CSS files, but nginx is still serving the old ones.

我尝试重新启动nginx,但没有成功,我已经使用Google搜索,但是找不到清除它的有效方法.

I have tried to restart nginx, to no success and I have Googled, but not found a valid way to clear it.

有些文章说我们只能删除缓存目录:var/cache/nginx,但是我的服务器上没有这样的目录.

Some articles say we can just delete the cache directory: var/cache/nginx, but there is no such directory on my server.

我现在该怎么办?

推荐答案

我遇到了完全相同的问题-我在Virtualbox中运行了Nginx.我没有打开缓存.但看起来sendfilenginx.conf中设置为on,这才引起了问题. @kolbyjack在上面的评论中提到了它.

I had the exact same problem - I was running my nginx in Virtualbox. I did not have caching turned on. But looks like sendfile was set to on in nginx.conf and that was causing the problem. @kolbyjack mentioned it above in the comments.

当我关闭sendfile时-工作正常.

When I turned off sendfile - it worked fine.

这是因为:

Sendfile用于在一个文件描述符和另一个文件描述符之间复制数据",当在虚拟机环境中运行或至少通过Virtualbox运行时,显然存在一些实际问题.在nginx中关闭此配置会导致通过其他方法提供静态文件,您的更改将立即得到体现,而不会出现任何问题

Sendfile is used to ‘copy data between one file descriptor and another‘ and apparently has some real trouble when run in a virtual machine environment, or at least when run through Virtualbox. Turning this config off in nginx causes the static file to be served via a different method and your changes will be reflected immediately and without question

它与以下错误有关: https://www.virtualbox.org/ticket/12597

这篇关于如何清除nginx的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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