开发者

Zend Framework : Zend_Cache_Frontend_Page not caching when using get parameters

I am using a code snippet to cache an entire page :

<?php

// Cache engine
// Cache everything outputed on the page for 2 minutes
// in the tmp folder

require_once 'Zend/Cache.php';

$frontendOptions = array(
   'lifetime' => 120,
   'automatic_serialization' => true,
   'cache_with_get_variables' => true,
   'cache_with_post_variables' => true,
   'cache_with_session_variables' => true,
   'cache_with_files_variables' => true,
   'cache_with_cookie_variables' => true
);

$backendOptions = array(
    'cache_di开发者_JAVA百科r' => '../tmp/'
);

$cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
$cache->start();

echo date("D M j G:i:s T Y");

?>

If I call the page using : http://localhost/myapp/cache.php it works PERFECTLY

If I call the page using with a get parameter : http://localhost/myapp/cache.php?test=5 the page is not cached

I use ZF 1.11.0

Thank you for your help !


Actually it's easy you have an error in you Frontend options, 'cache_with_XXX_variables' need to be in an array with the key 'default_options':

$frontendOptions = array(
   'lifetime' => 120,
   'automatic_serialization' => true,
   'default_options' => array(
            'cache' => true,
            'cache_with_get_variables' => true,
            'cache_with_post_variables' => true,
            'cache_with_session_variables' => true,
            'cache_with_files_variables' => true,
            'cache_with_cookie_variables' => true,
        )
);


I think you have to modify your frontendOptions:

    'make_id_with_get_variables' => true,
    'make_id_with_post_variables' => true,
    'make_id_with_session_variables' => true,
    'make_id_with_files_variables' => true,
    'make_id_with_cookie_variables' => true,
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜