Zend Framework:使用获取参数时 Zend_Cache_Frontend_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_dir' => '../tmp/'
);
$cache = Zend_Cache::factory('Page', 'File', $frontendOptions, $backendOptions);
$cache->start();
echo date("D M j G:i:s T Y");
?>
如果我使用以下方式调用该页面: http://localhost/myapp/cache.php 它会完美工作
如果我使用 get 参数调用该页面, : http://localhost/myapp/cache.php?test=5 该页面未缓存
我使用 ZF 1.11.0
谢谢您的帮助!
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_dir' => '../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 !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,前端选项中很容易出现错误,“cache_with_XXX_variables”需要位于带有“default_options”键的数组中:
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:
I think you have to modify your frontendOptions: