当我尝试缓存私有图像(带有修改标题的动作)时,标题被省略
我有以下行动:
public function viewImageAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$filename = sanitize_filename($this->_request->getParam('file'), 'jpg');
$data = file_get_contents(APPLICATION_PATH . '/../private-files/fans-pictures/' . $filename);
$this->getResponse()
->setHeader('Content-type', 'image/jpeg')
->setBody($data);
}
在应用程序启动之前的index.php中,我有:
/** Zend Cache to avoid unecessary application load **/
require_once 'Zend/Cache.php';
$frontendOptions = array(
'lifetime' => 3600,
'default_options' => array(
'cache' => $cache_flag,
'cache_with_cookie_variables' => true,
'make_id_with_cookie_variables' => false),
'regexps' => array(
'^(/.+)?/admin/?' => array('cache' => false),
'^(/.+)?/pictures/view-image/?' => array('cache' => true),
'^(/.+)?/authentication/?' => array('cache' => false),
'^(/.+)?/fan-profile/?' => array('cache' => false),
'^(/.+)?/fan-registration/?' => array('cache' => false))
);
$backendOptions = array(
'cache_dir' => APPLICATION_PATH . '/cache/pages/');
$cache = Zend_Cache::factory(
'Page', 'File', $frontendOptions, $backendOptions
);
$cache->start();
缓存工作正常,除非我尝试访问网址,如public/admin/pictures/view-image/file/63.jpg
,标题附带text/html
而不是image/jpeg
。
难道我做错了什么?
EDITED
我试过了:
'memorize_headers' => array('Content-type')
但没什么......
此外,我注意到这种类型的缓存(在应用程序启动之前)无法在管理区域上完成,因为应用程序需要运行并检查会话。所以我需要尽快放置chache以避免所有组件的负载。
有小费吗?
没有找到相关结果
已邀请:
1 个回复
导力疵谜
参数的位置。 我在尝试这个:
正确的位置是
键:
现在它有效。