`
ping8899
  • 浏览: 44553 次
社区版块
存档分类
最新评论

php session_cache_limiter详解

阅读更多

    <span style="background-color: #eeeeee;">
</span>

<h2 style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; line-height: 19px; margin-top: 10px; font-size: 1em;"><a id="ctl09_TitleUrl" style="color: #0000ff; text-decoration: none; font-size: 13px;" href="http://www.cnblogs.com/kaixin110/archive/2010/09/06/1818830.html">session_cache_limiter(private,must-revalidate)是什么意思</a></h2>
<div id="cnblogs_post_body">
<ul class="row-1" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-left: 45px; border-bottom-width: 0px; border-bottom-style: none; border-bottom-color: initial;">
<li id="articleContent" class="pro-content">

<div>
<div style="width: 760px;">
<p style="font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">表义一:

<p style="font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">表义二:



</li>
</ul>
<p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">?

<p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">?

<p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">?

<ul style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-left: 45px;">
  • 1.使用session_cache_limiter方法:

  • </ul>
    <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: x-small;"><span style="line-height: 19px;"><span style="white-space: pre;"> </span></span></span>


    <span style="line-height: 19px; white-space: pre; background-color: #fafafa;">session_cache_limiter('private,must-revalidate');  </span><span style="background-color: #eeeeee;">
    <div>
    <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: x-small;"><span style="line-height: 19px;">?<br></span></span>
    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">但是要值得注意的是session_cache_limiter()方法要写在session_start()方法之前才有用;

    <ul style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-left: 45px;">
  • 2.用header来设置控制缓存的方法:

  • </ul>
    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">?

    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">第一,使用Header方法设置消息头Cache-control?<br>引用:<br>header('Cache-control: private, must-revalidate');//支持页面回跳<br>第二,使用session_cache_limiter方法?<br>引用:<br>//注意要写在session_start方法之前<br>session_cache_limiter('private, must-revalidate');

    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">Public指示响应可被任何缓存区缓存。

    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">no-cache指示请求或响应消息不能缓存

    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">max-age指示客户机可以接收生存期不大于指定时间(以秒为单位)的响应。

    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">max-stale指示客户机可以接收超出超时期间的响应消息。如果指定max-stale消息的值,那么客户机可以接收超出超时期指定值之内的响应消息。

    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">问:为什么我在点击浏览器的后退按钮后,所有字段的信息都被清空了?

    <p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; text-indent: 0px;">补充:还有基于session的解决方法,在session_start前加上?<br>引用:<br>session_cache_limiter('nocache');// 清空表单<br>session_cache_limiter('private'); //不清空表单,只在session生效期间<br>session_cache_limiter('public'); //不清空表单,如同没使用session一般


    </span>
    ?

     
    0
    0
    分享到:
    评论

    相关推荐

      基于session_unset与session_destroy的区别详解

      - session.cache_limiter和session.cache_expire用于控制会话页面的缓存问题,影响到HTTP头信息的设置。 - session.use_trans_sid用于启用或禁用透明sid支持。 - url_rewriter.tags用于定义URL重写时应重写的标签...

      php session的应用详细介绍

      使用session_cache_limiter()函数可以设置缓存的限制类型,可以是public或private。设置Session缓存的时间限制则使用session_cache_expire()函数,并且该函数也需要在session_start()函数之前执行。 Session的...

      让PHP支持页面回退的两种方法[转]

      除了通过HTTP头部控制缓存行为之外,还可以利用PHP会话管理机制中的`session_cache_limiter()`函数来达到类似的效果。这种方法的优势在于它可以在启动会话的同时就设定好缓存限制,从而简化代码逻辑。 ```php ...

      一份超级全面的PHP面试题

      使用`session_set_cookie_params()`或`session_cache_limiter()`函数。 17、获取网页内容: 使用`file_get_contents()`函数。 18、HTTP 1.0中,状态码401表示未授权,`header('HTTP/1.0 404 Not Found');`返回找...

      ThinkPHP中session函数详解

      7. `cache_limiter`: 设置HTTP缓存限制器,影响session cookie的类型。 8. `cache_expire`: 设置缓存过期时间,通常与session的生命周期一致。 ThinkPHP框架还提供了灵活的session存储方式,可以通过配置选项 `...

      关于session在PHP5的配置文件中的详细设置参数说明

      **PHP5中的Session配置详解** Session是PHP提供的一种在用户之间保持状态的机制,它使得在用户的不同请求间共享数据成为可能。在PHP5中,Session的配置主要通过php.ini文件进行,涉及到多个参数,这些参数对Session...

      php_web项目中utf-8的问题.do

      BOM标记会导致诸如`Warning: session_start(): Cannot send session cache limiter - headers already sent`之类的错误,因为PHP将BOM视为输出的一部分。解决方法同上,使用Dreamweaver或EditPlus移除BOM。 4. **以...

    Global site tag (gtag.js) - Google Analytics