PHP或Apache似乎是通过缓存的file_get_contents读取文件或包括(不必要的行为) [英] PHP or Apache seems to be caching files read via file_get_contents or include (unwanted behaviour)

查看:1353
本文介绍了PHP或Apache似乎是通过缓存的file_get_contents读取文件或包括(不必要的行为)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的Web应用程序有获得服务到客户端上的每个请求,所以我们可以检测更新到code(即滚动更新)的版本号,并显示一个弹出通知他们重新加载采取的最新优势更新。

Our web application has version numbers that get served out to the client on each request so we can detect an update to the code (ie rolling updates) and displays a popup informing them to reload to take advantage of the latest update.

但我遇到的服务器,其中一些请求返回新的版本号和一些返回旧的版本号的更新之后,一些奇怪的行为,所以弹出保持坡平了,直到你重新加载页面数倍。

But I'm experiencing some weird behaviour after the update of the version number on the server, where some requests return the new version number and some return the old, so the popup keeps poping up until you have reloaded the page a few times.

本来我怀疑也许阿帕奇缓存文件它读出的file_get_contents通过磁盘,以便而不是存储在一个纯文本文件的版本号,我现在其存储在被包含在每个请求的PHP文件,但我经历完全相同的问题!

Originally I suspected maybe apache was caching files it read off disk via file_get_contents so instead of storing the version number in a plain text file, I now store it in a php file that gets included with each request, but I'm experiencing the exact same issue!

任何人有任何想法什么可能导致Apache或PHP它的自我要服完旧的信息我已经做了更新后?

Anyone have any ideas what might be causing apache or php it self to be serving out old information after i have done an update?

编辑:我已证实它不是浏览器缓存,因为我可以有客户端生成唯一的URL到服务器(它可以处理通过重写),我仍然看到一些请求返回旧版本号相同​​的问题,有些新,并清除浏览器缓存并不能帮助

I have confirmed its not browser caching as I can have the client generate unique urls to the server (that it can deal with via rewrite) and i still see the same issue where some requests return the old version number and some the new, and clearing the browser cache doesn't help

编辑2:作为请求的响应头

EDIT 2: The response headers as requested

HTTP/1.1 200 OK
Date: Mon, 23 Jul 2012 16:50:53 GMT
Server: Apache/2.2.14 (Ubuntu)
X-Powered-By: PHP/5.3.2-1ubuntu4.7
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
Expires: Sat, 26 Jul 1997 05:00:00 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 500
Connection: close
Content-Type: text/html

编辑3:因此,试图重现得到响应头,我发现我只能做到这一点通过我们这包括创建版本控制的目录存放code和符号链接的初步认识到文件夹的根目录全面部署过程中去。只是改变了版本号是不够的,导致它发生!所以,似乎不知何故与我创建符号链接!

EDIT 3: So trying to reproduce to get the response headers I found I could only make it happen going through our full deploy process which involves creating versioned folders storing the code and symlinking the relavant folder into the webroot. Just changing the version number wasn't enough to cause it to happen! So seems to be somehow related to the symlinks i create!

推荐答案

我有同样的问题时,有一个在符号链接的变化。看看 https://bugs.php.net/bug.php?id=36555 它也许你正在寻找的东西。

I have the same problem when there is a change in the symlink. Have a look at https://bugs.php.net/bug.php?id=36555 it's maybe what you are looking for.

尝试(因为这个bug报告中称)设置realpath_cache_size为0。

Try (as said in this bug report) setting realpath_cache_size is 0.

这篇关于PHP或Apache似乎是通过缓存的file_get_contents读取文件或包括(不必要的行为)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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