session_cache_limiter() - php 会话函数session
session_cache_limiter()
(PHP 4 >= 4.0.3, PHP 5, PHP 7)
读取/设置缓存限制器
说明
session_cache_limiter([string $cache_limiter]): stringsession_cache_limiter()返回当前缓存限制器的名称。
缓存限制器定义了向客户端发送的 HTTP 响应头中的缓存控制策略。客户端或者代理服务器通过检测这个响应头信息来确定对于页面内容的缓存规则。设置缓存限制器为nocache会进制客户端或者代理服务器缓存内容,public表示允许客户端或代理服务器缓存内容,private表示允许客户端缓存,但是不允许代理服务器缓存内容。
在private模式下,包括Mozilla在内的一些浏览器可能无法正确处理 Expire 响应头,通过使用private_no_expire模式可以解决这个问题:在这种模式下,不会向客户端发送Expire响应头。
设置为''可以关闭自动发送缓存策略响应头的功能。
请求开始的时候,缓存限制器会被重置为默认值,并且存储在session.cache_limiter配置项中。因此,如果要设置缓存限制器,对于每个请求,都需要在调用session_start()函数之前,调用session_cache_limiter()函数来进行设置。
参数
$cache_limiter如果指定了$cache_limiter参数,将使用指定值作为缓存限制器的值。
值 | 发送的响应头 |
---|---|
public | Expires:(根据 session.cache_expire 的设定计算得出) Cache-Control: public, max-age=(根据 session.cache_expire 的设定计算得出) Last-Modified:(会话最后保存时间) |
private_no_expire | Cache-Control: private, max-age=(根据 session.cache_expire 的设定计算得出), pre-check=(根据 session.cache_expire 的设定计算得出) Last-Modified: (会话最后保存时间) |
private | Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: private, max-age=(根据 session.cache_expire 的设定计算得出), pre-check=(根据 session.cache_expire 的设定计算得出) Last-Modified: (会话最后保存时间) |
nocache | Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache |
返回值
返回当前所用的缓存限制器名称。
范例
Example #1session_cache_limiter()示例
参见
- session.cache_limiter
If you are trying to work with dynamic binaries such as videos or images, the new IE 7 appears to require the ETag header. You will need to make sure that you follow the specifications for how ETag works in order for your cache control to work properly. Mozilla supports the ETag header as well, but does NOT require it for caching. If you need to cache a dynamic image, video, or other binary file, then be sure to set your ETag and then check for the If-Not-Modified header on subsequent requests so that you can properly return the 304 Not Modified page.
IE6 'the file could not be written to the cache': I tried all the other suggestions mentioned here but none of them worked. I friend suggested header("Pragma: "); This worked straight away!
I have PHP 4.3 running on a Windows 2003 Server running IIS 6.0 also using SSL encryption for my pages. I could not (for the life of me) figure out how to get IE 6.0/WinXPPro to recognize a set of HTML tables as an Excel spreadsheet export, and it was due to the header() variables I was using. Hopefully these are helpful to others who are attempting the same type of export within PHP. *This example builds on the previously submitted one, adding a few necessary headers.
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!