如何停用浏览器中的缓存?
例如,如果您退出雅虎邮件,然后单击后退按钮,它不会加载最后一页,而是将您重定向到登录页面。
我必须用我的 PHP 代码来完成此操作,我正在使用 CodeIgniter。
有些朋友告诉我禁用缓存,但这将是一件坏事,因为我的系统中有很多图像,每次都下载它们会很糟糕。
我如何使用 PHP 来做到这一点?
For instance, if you exit your Yahoo mail and then click the back button, it will not load the last page, it will redirect you to the login page.
I have to do this with my PHP code, I'm using CodeIgniter.
Some friends told me to disable caching but that will be a bad thing because I have a lot of images in my system and it would be bad to download them every time.
How do I do this with PHP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用以下代码禁用页面缓存:
http://php.net/manual/en /function.header.php
Disable caching of your page with the following code :
http://php.net/manual/en/function.header.php
试试这些:
Try these:
避免在客户端浏览器上进行缓存的简单答案是配置 Cache-Control HTTP 响应标头。
但是
,我不知道我没有 PHP 代码片段来向您展示如何准确地做到这一点。它应该像获取 HTTP 响应对象一样简单,并设置一个标头“Cache-Control”,其值为“no-store,must-revalidate”
The simple answer to avoid caching on the client browsers is to configure the Cache-Control HTTP response header.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Avoiding_caching
However, I don't have a PHP snippet with me to show you how to do it exactly. It should as simple getting the HTTP response object, and setting a header "Cache-Control" with value "no-store, must-revalidate"