#php #zend-framework #cache-control
#php #zend-framework #управление кэшем
Вопрос:
Я использую фрагмент кода для кэширования всей страницы :
<?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
Спасибо за вашу помощь!
Ответ №1:
На самом деле это просто, у вас ошибка в настройках вашего интерфейса, ‘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,
)
);
Ответ №2:
Я думаю, вам нужно изменить свои параметры интерфейса:
'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,
Комментарии:
1. Привет, спасибо за ваш ответ, но он по-прежнему не работает (и он должен работать без ваших изменений). Моя цель — заставить кэш работать даже с параметром get (я еще не на том этапе, чтобы иметь один идентификатор по значению get …). Прямо сейчас кэш вообще не работает с параметром get…