Zend Framework:使用获取参数时 Zend_Cache_Frontend_Page 不缓存

发布于 2024-11-05 10:27:23 字数 1010 浏览 2 评论 0原文

我正在使用代码片段来缓存整个页面:

<?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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

煮茶煮酒煮时光 2024-11-12 10:27:23

实际上,前端选项中很容易出现错误,“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,
        )
);

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,
        )
);
比忠 2024-11-12 10:27:23

我认为你必须修改你的 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,

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,
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文