简体   繁体   English

nginx + php-fpm忽略无缓存头

[英]nginx + php-fpm ignores no-cache headers

I'm using the following header on a php page. 我在php页面上使用以下标头。

 // Prevent page caching.
 header('Expires: Tue, 20 Oct 1981 05:00:00 GMT'); 
 header('Cache-Control: no-store, no-cache, must-revalidate'); 
 header('Cache-Control: post-check=0, pre-check=0', FALSE); 
 header('Pragma: no-cache');

I'm also using a rand=999999999 (with a real random number) in the URLs. 我还在网址中使用rand = 999999999(带有一个随机数)。

But pages are still being cached. 但是页面仍在缓存中。 Reload works, but first load is cached. 重新加载有效,但第一次加载已缓存。 Anyone know where I can change this? 有人知道我可以在哪里更改吗?

Your problem is most probably some combination of the browser, the operating system and the proxy you are using. 您的问题很可能是浏览器,操作系统和所用代理的某种组合。 Therefore... 因此...

a) Stop using IE to test a web application until you know your application works 100% in at least two decent browsers that actually try to adhere to standards. a)停止使用IE测试Web应用程序,直到您知道您的应用程序在至少两个实际尝试遵守标准的体面的浏览器中可以100%正常工作。 FF has good dev tools and is recommended. FF具有良好的开发工具,值得推荐。

b) Reboot windows and clear your cache. b)重新启动窗口并清除缓存。 Set up FF to check every visit. 设置FF检查每次访问。 Disable any local proxy for the test site. 禁用测试站点的任何本地代理。 Now test. 现在测试。 Get that working. 让它工作。 Check the logs on the server to prove that caching took place. 检查服务器上的日志以证明已进行缓存。 If it was served, it wasn't cached. 如果已提供,则不会被缓存。

c) Then try testing with IE. c)然后尝试使用IE进行测试。 Fix the layout (without breaking it for decent browsers). 修复布局(对于体面的浏览器不要破坏它)。 Fix the javascript errors that have appeared with IE (again without breaking for other browsers). 修复IE中出现的javascript错误(同样适用于其他浏览器)。 Fix everythgin else that is wrong in IE - all without breaking the working code. 修复IE中所有其他错误的东西-所有这些都不会破坏工作代码。 (Stop cursing MS - its not good for your health). (停止诅咒MS-不利于您的健康)。

d) Leave the remaining bugs for IE users - some bugs in IE cannot be got round.:( d)将其余的错误留给IE用户-IE中的一些错误无法解决。

OK - I'll admit to guessing a bit about the reasons for your trouble. 好的-我会猜测一下造成麻烦的原因。 Had the same sort of trouble with windows and IE. Windows和IE也有同样的麻烦。 The above is a practical solution. 以上是一个实际的解决方案。

ps I've used nginx and fastcgi for over 2 years. ps我已经使用nginx和fastcgi超过2年了。 Never had any problems. 从来没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM