Php Zend Framework:Zend_缓存_前端_页面在使用get参数时不缓存
我正在使用代码片段缓存整个页面:Php Zend Framework:Zend_缓存_前端_页面在使用get参数时不缓存,php,zend-framework,cache-control,Php,Zend Framework,Cache Control,我正在使用代码片段缓存整个页面: <?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, 'ca
<?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_dir' => '../tmp/'
);
$cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
$cache->start();
echo date("D M j G:i:s T Y");
?>
如果我使用以下命令调用页面:
它工作得很好
如果使用get参数调用页面:
该页未被缓存
我使用ZF1.11.0
谢谢你的帮助 我认为您必须修改您的FrontInOptions:
'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,
实际上,前端选项中很容易出现错误,“cache_with_XXX_variables”需要位于一个带有键“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,
)
);
您好,谢谢您的回复,但它仍然不起作用(没有您的修改它应该可以工作)。我的目标是使缓存工作,即使使用get参数也是如此(我还没有按get值获得一个id…)。现在,缓存对于get参数根本不起作用。。。