I created simple application resource,
which uses php's gzencode function to compress response body.
Everything works fine,
but when I enable Zend_Cache_Page,
I get strange characters before DOCTYPE:
�������X��
and after </html> tag:
��$nX��
How to solve this problem?
Here is how I setup the cache in index.php:
$cache = Zend_Cache::factory('Page', 'File',
// FRONTEND options
array(
'lifetime' => 1727200,
'automatic_serialization' => true,
'default_options' => array(
'cache'=>true,
'cache_with_cookie_variables' => true,
'make_id_with_cookie_variables' => false,
),
),
// BACKEND options
array(
'cache_dir' => APPLICATION_PATH . '/../data/cache/',
)
);
$cache->start();
require 'Zend/Registry.php';
Zend_Registry::set('cache', $cache);
unset($cache);
This is how I compress the output in my custom response:
public function sendResponse()
{
$body = $this->getBody();
$bodyGzipped = gzencode($body);
$this->setBody($bodyGzipped);
$this->setHeader('Content-Encoding', 'gzip', true);
$this->setHeader('Vary', 'Accept-Encoding', true);
$this->setHeader('Content-Length', mb_strlen($bodyGzipped,
'UTF-8'), true);
parent::sendResponse();
}
--
regards
takeshin
--
View this message in context:
http://n4.nabble.com/Zend-Cache-Page-and-gzip-issues-tp997990p997990.html
Sent from the Zend Framework mailing list archive at Nabble.com.