开发者

Changing view caching config in CakePHP

开发者 https://www.devze.com 2022-12-21 06:49 出处:网络
I am working on a project in cakephp where one app will support multiple sites using different domains. This is an issue when using view caching where it only matches to the end part of the url and ig

I am working on a project in cakephp where one app will support multiple sites using different domains. This is an issue when using view caching where it only matches to the end part of the url and ignores the host.

Is there a way to prefix view caching with the host so that there isn't any conflict across different s开发者_如何学Goites?


You can use a different cache configuration for each domain, like this:

app/config/core.php

switch(@$_SERVER['SERVER_NAME']) {
    case 'example.com':
        Cache::config('default', array(
            'engine' => 'File',
            'prefix' => 'example_com_'
        ));
    break;

    case 'example2.com':
        Cache::config('default', array(
            'engine' => 'File',
            'prefix' => 'example2_com_'
        ));
    break;

    default:
        Cache::config('default', array(
            'engine' => 'File',
            'prefix' => 'default_'
        ));
    break;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消