3
我有以下作用:当我尝试缓存私有映像(与体改头动作),头被省略
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();
缓存工作正常,但如果我尝试访问的URL,像public/admin/pictures/view-image/file/63.jpg
头配备text/html
不image/jpeg
。
我做错了什么?
EDITED
我已经试过:
'memorize_headers' => array('Content-type')
但没有......
而且,我已经注意这个缓存类型(应用程序开始之前)就可以不会在管理区域完成,因为应用程序需要运行并检查会话。所以我需要尽快把chache放在一起,以避免涉及所有组件的负载。
任何提示?
你可以检查一个保存的缓存文件,看看它是否实际存储头文件?你应该能够找到一个名为'headers'的序列化项'“...; s:7:”headers“; a:0:{}} ...这是一个没有头文件保存的例子。不保存它们,还有另一个问题,如果是保存它们,那么这就是为什么它们没有被重放的问题。 – 2010-11-25 21:43:31