我正在使用cakephp 2.x
我有一个静态页面(多语言)和cacheAction的网站。
缓存不识别该语言,并以最火的语言缓存页面。
有没有办法解决(禁用缓存的一部分?)谢谢,马西莫
class PagesController extends AppController {
/**
* This controller does not use a model
*
* @var array
*/
public $uses = array();
public $helpers = ['Cache','AbTest.AbTest'];
public $cacheAction = '1 month';
public $components = array('AbTest.AbTest');……
if ($locale && file_exists(APP . 'View' . $theme_path . DS . $this->viewPath . DS . $locale .DS. implode('/', $path) . $this->ext ))
{
array_unshift($path,$locale);
}
try {
$this->render(implode('/', $path));
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}我希望缓存将ita/ pages /who和eng/pages/who显示为不同的页面,而它总是输出ita/pages/who
发布于 2019-05-30 16:12:40
为此,有一个称为Cache.viewPrefix的选项。您没有提到如何管理站点中的语言,但基本的逻辑是,您可以使用语言设置缓存文件前缀,这样您就可以为每种语言创建单独的缓存文件。例如,您可以在您的PagesController或AppController中这样做
Configure::write('Cache.viewPrefix', /* place the language here */);
https://stackoverflow.com/questions/56171976
复制相似问题