nginx + php-fpm 忽略无缓存标头
我在 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');
我还在 URL 中使用 rand=999999999 (带有真实的随机数)。
但页面仍在缓存中。重新加载有效,但第一次加载会被缓存。有人知道我可以在哪里改变这个吗?
I'm using the following header on a php page.
// 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.
But pages are still being cached. Reload works, but first load is cached. Anyone know where I can change this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题很可能是您所使用的浏览器、操作系统和代理的某种组合造成的。因此...
a) 停止使用 IE 来测试 Web 应用程序,直到您知道您的应用程序在至少两个实际上尝试遵守标准的不错的浏览器中 100% 运行。 FF 有很好的开发工具,推荐。
b) 重新启动 Windows 并清除缓存。设置FF来检查每次访问。禁用测试站点的任何本地代理。现在测试一下。让它发挥作用。检查服务器上的日志以证明已进行缓存。如果已提供,则不会缓存。
c) 然后尝试使用 IE 进行测试。修复布局(不会破坏正常浏览器的布局)。
修复 IE 中出现的 JavaScript 错误(同样不会破坏其他浏览器)。修复 IE 中的所有其他错误 - 所有这些都不会破坏工作代码。 (别再咒骂多发性硬化症了——这对你的健康没有好处)。
d) 将剩下的 bug 留给 IE 用户 - IE 中的一些 bug 无法解决。:(
好吧 - 我承认我猜测了一些你遇到麻烦的原因。Windows 和 IE 也遇到了同样的麻烦。上面是一个实用的解决方案。
ps 我使用 nginx 和 fastcgi 已经有 2 年多了,从来没有遇到过任何问题。
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. FF has good dev tools and is recommended.
b) Reboot windows and clear your cache. Set up FF to check every visit. 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. Fix the layout (without breaking it for decent browsers).
Fix the javascript errors that have appeared with IE (again without breaking for other browsers). Fix everythgin else that is wrong in IE - all without breaking the working code. (Stop cursing MS - its not good for your health).
d) Leave the remaining bugs for IE users - some bugs in IE cannot be got round.:(
OK - I'll admit to guessing a bit about the reasons for your trouble. Had the same sort of trouble with windows and IE. The above is a practical solution.
p.s. I've used nginx and fastcgi for over 2 years. Never had any problems.