当使用PHP Yaf框架,如果某个 Action 在返回响应(输出页面或者返回json)之前,启用了session,那么将会在响应头里面加上强制不缓存的响应头,也就是如下的三个响应头。
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
测试代码
class IndexController extends Yaf_Controller_Abstract {
// 带有session
public function sessionAction() {
$sessionInstance = \Yaf_Session::getInstance();
$this->getView()->assign("content", "Hello World");
$this->display("index");
return false;
}
// 没有session
public function noSessionAction() {
$this->getView()->assign(www.fengshen157.com"content", "Hello World");
$this->display("index");
return false;
}
}
启用session的请求响应
$ curl -si http://127.0.0.1/index/session
HTTP/1.1 200 OK
Server: openresty/1.11.2.5
Date: Wed, 20 Feb 2019 02:54:47 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/7.0.25
Set-Cookie: PHPSESSID=lf72vsbla12b2431evhp9mq7l6; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store,www.078881.cn no-cache, must-revalidate
Pragma: no-cache
<html>
<head>
<title>Hello World<www.tianshengyuLe1.cn /title>
</head>
<body>
Hello World </body>
</html>
浅谈 PHP Yaf 开启session之后对响应头的影响
最新推荐文章于 2020-08-26 14:48:57 发布