diff --git a/app/Config/core.php b/app/Config/core.php index d31e5f32d..ad5c50f03 100644 --- a/app/Config/core.php +++ b/app/Config/core.php @@ -129,6 +129,16 @@ */ //Configure::write('Cache.check', true); +/** + * Enable cache view prefixes. + * + * If set it will be prepended to the cache name for view file caching. This is + * helpful if you deploy the same application via multiple subdomains and languages, + * for instance. Each version can then have its own view cache namespace. + * Note: The final cache file name will then be `prefix_cachefilename`. + */ + //Configure::write('Cache.viewPrefix', 'prefix'); + /** * Defines the default error type when using the log() function. Used for * differentiating error logging and debugging. Currently PHP supports LOG_DEBUG. diff --git a/lib/Cake/Console/Templates/skel/Config/core.php b/lib/Cake/Console/Templates/skel/Config/core.php index 21a12565b..569087215 100644 --- a/lib/Cake/Console/Templates/skel/Config/core.php +++ b/lib/Cake/Console/Templates/skel/Config/core.php @@ -129,6 +129,16 @@ */ //Configure::write('Cache.check', true); +/** + * Enable cache view prefixes. + * + * If set it will be prepended to the cache name for view file caching. This is + * helpful if you deploy the same application via multiple subdomains and languages, + * for instance. Each version can then have its own view cache namespace. + * Note: The final cache file name will then be `prefix_cachefilename`. + */ + //Configure::write('Cache.viewPrefix', 'prefix'); + /** * Defines the default error type when using the log() function. Used for * differentiating error logging and debugging. Currently PHP supports LOG_DEBUG. diff --git a/lib/Cake/Routing/Filter/CacheDispatcher.php b/lib/Cake/Routing/Filter/CacheDispatcher.php index 0bc305d89..688ccb3af 100644 --- a/lib/Cake/Routing/Filter/CacheDispatcher.php +++ b/lib/Cake/Routing/Filter/CacheDispatcher.php @@ -42,9 +42,13 @@ class CacheDispatcher extends DispatcherFilter { } $path = $event->data['request']->here(); - if ($path == '/') { + if ($path === '/') { $path = 'home'; } + $prefix = Configure::read('Cache.viewPrefix'); + if ($prefix) { + $path = $prefix . '_' . $path; + } $path = strtolower(Inflector::slug($path)); $filename = CACHE . 'views' . DS . $path . '.php'; diff --git a/lib/Cake/View/Helper/CacheHelper.php b/lib/Cake/View/Helper/CacheHelper.php index 02ecc1147..9c5d153b7 100644 --- a/lib/Cake/View/Helper/CacheHelper.php +++ b/lib/Cake/View/Helper/CacheHelper.php @@ -278,9 +278,13 @@ class CacheHelper extends AppHelper { $cacheTime = strtotime($timestamp, $now); } $path = $this->request->here(); - if ($path == '/') { + if ($path === '/') { $path = 'home'; } + $prefix = Configure::read('Cache.viewPrefix'); + if ($prefix) { + $path = $prefix . '_' . $path; + } $cache = strtolower(Inflector::slug($path)); if (empty($cache)) {