我想让这样的事情:如何更改响应头在zend_action
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
header('HTTP/1.1 304 Not Modified');
exit;
}
...... other code .....
打字做这种方式:
public function imageAction()
{
$request = $this->getRequest();
$response = $this->getResponse();
if ($request->getHeader('IF_MODIFIED_SINCE')) {
$response->setHttpResponseCode(304);
return;
}
var_dump($request->getHeaders());
$response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', time()).' GMT');
var_dump($response->getHeaders());
echo '11111';
exit;
希望结果的读者必须像
> this: Date: Thu, 07 Jul 2011 09:28:08
> GMT Server: Apache/2.2.15 (Linux/SUSE)
> X-Powered-By: PHP/5.3.7RC2-dev
> Last-Modified: Thu, 07 Jul 2011
> 09:27:48 GMT Content-Length: 7101
> Content-Type: text/html
>
> 200 OK
但它总是:
> Date: Thu, 07 Jul 2011 09:30:16 GMT
> Server: Apache/2.2.15 (Linux/SUSE)
> X-Powered-By: PHP/5.3.7RC2-dev
> 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
> Content-Length: 347 Keep-Alive:
> timeout=15, max=99 Connection:
> Keep-Alive Content-Type: text/html
>
> 200 OK
或者我必须使用zend_cache?
确保你没有行“头取消设置的Last-Modified”在你的.htaccess文件 – evilReiko