缓存控制失败 [英] Cache Control fails

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

问题描述

  session_cache_limiter('nocache'); 
session_start();
header('Cache-Control:no-cache,must-revalidate,post-check = 0,pre-check = 0');

防止浏览器缓存页面。我检查了Firefly中的头文件输出,他们一直说:

  Cache-Control:private,max-age = 10800, pre-check = 10800 

我以前在HTML META中有这个功能:

 < META HTTP-EQUIV =cache-controlcontent =no-cache/> 
< META HTTP-EQUIV =PragmaCONTENT =no-cache>
< META HTTP-EQUIV =ExpiresCONTENT = - 1>

但是已经禁用了这些以检查它们是否有干扰,但启用或禁用了



所有帮助表示感谢!

解决方案


FireFly中的标头输出仍然是Cache-Control私有的,
max-age = 10800,预检查= 10800,no-cache,必须重新验证,
post-check = 0 ,pre-check = 0


这意味着您正在设置此项:

  Cache-Control:no-cache,must-revalidate,post-check = 0,pre-check = 0 

$ p
$ b pre $ Cache-Control:private,max-age = 10800,pre-check = 10800

以及两者被发送给最终用户。当浏览器读取它们时,Cache-Control:private将覆盖您的值,导致页面被缓存。



注意: header()默认会覆盖之前设置的任何标题,所以可能是某些设置 在你的代码行之后,因为你的代码行应该覆盖任何以前的代码。



你需要找出设置那些私有缓存控制标题和禁用/评论,否则它将无法正常工作。也许以后在你的代码中的其他部分?


My index.php page keeps being cached, showing old timer values and others, even though I'm using this:

session_cache_limiter( 'nocache' );
session_start( );
header( 'Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0' );

to keep the browser from caching the page. I've checked the headers output in Firefly and they keep saying:

Cache-Control:private, max-age=10800, pre-check=10800

I used to have this in the HTML META:

<META HTTP-EQUIV="cache-control" content="no-cache" />
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

But have already disabled those in order to check if they were interfering, but enabled or disabled doesn't make a difference.

All help is appreciated!

解决方案

Headers output in FireFly is still Cache-Control private, max-age=10800, pre-check=10800, no-cache, must-revalidate, post-check=0, pre-check=0

This implies that since you are setting this:

Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0

Some other component/configuration in your app/page is setting this:

Cache-Control: private, max-age=10800, pre-check=10800

and both are sent to the end user. The "Cache-Control: private" overrides your values when browser reads them, causing the page to be cached.

Note: header() will by default override any headers that are previously set, so it might be that something is setting that after your line of code, since your line should override any previous ones.

You need to find out what is setting those "private" cache-control headers and disable/comment that, otherwise it will not work. Maybe some other section later in your code?

这篇关于缓存控制失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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