开发者

Changing view caching config in CakePHP

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜