mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
cache prefix for view cache to avoid collisions with domains/languages
This commit is contained in:
parent
6bfbce128f
commit
32f2426001
4 changed files with 30 additions and 2 deletions
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue