diff --git a/code/site/components/com_pages/config.php b/code/site/components/com_pages/config.php index 8fc4c79d..e1897eb6 100644 --- a/code/site/components/com_pages/config.php +++ b/code/site/components/com_pages/config.php @@ -10,12 +10,14 @@ class ComPagesConfig extends KObject implements KObjectSingleton { protected $_site_path; + protected $_cache_path; public function __construct(KObjectConfig $config) { parent::__construct($config); - $this->_site_path = $config->site_path; + $this->_site_path = $config->site_path; + $this->_cache_path = $config->cache_path; //Load the site specific options $this->_loadOptions(); @@ -24,23 +26,25 @@ public function __construct(KObjectConfig $config) protected function _initialize(KObjectConfig $config) { $config->append(array( - 'site_path' => Koowa::getInstance()->getRootPath().'/joomlatools-pages' + 'site_path' => Koowa::getInstance()->getRootPath().'/joomlatools-pages', + ))->append(array( + 'cache_path' => $config->site_path.'/cache', ))->append(array( 'page_cache' => true, - 'page_cache_path' => $config->site_path.'/cache/pages', + 'page_cache_path' => $config->cache_path, 'page_cache_validation' => true, 'data_namespaces' => array(), 'data_cache' => true, - 'data_cache_path' => $config->site_path ? $config->site_path.'/cache/data' : false, + 'data_cache_path' => $config->cache_path ? $config->cache_path.'/data' : false, 'data_cache_validation' => true, 'template_cache' => true, - 'template_cache_path' => $config->site_path ? $config->site_path.'/cache/templates' : false, + 'template_cache_path' => $config->cache_path ? $config->cache_path.'/templates' : false, 'template_cache_validation' => true, 'http_cache' => false, - 'http_cache_path' => $config->site_path ? $config->site_path.'/cache/responses': false, + 'http_cache_path' => $config->cache_path ? $config->cache_path.'/pages': false, 'http_cache_time' => false, 'http_cache_time_browser' => null, 'http_cache_validation' => true, @@ -50,9 +54,9 @@ protected function _initialize(KObjectConfig $config) 'http_static_cache' => getenv('PAGES_STATIC_ROOT') ? true : false, 'http_static_cache_path' => getenv('PAGES_STATIC_ROOT') ? getenv('PAGES_STATIC_ROOT') : false, - 'http_resource_cache' => JFactory::getConfig()->get('caching'), - 'http_resource_cache_path' => $config->site_path ? $config->site_path.'/cache/resources' : false, - 'http_resource_cache_debug' => (JDEBUG ? true : false), + 'http_client_cache' => JFactory::getConfig()->get('caching'), + 'http_client_cache_path' => $config->cache_path ? $config->cache_path.'/responses' : false, + 'http_client_cache_debug' => (JDEBUG ? true : false), 'collections' => array(), 'redirects' => array(), @@ -77,6 +81,11 @@ public function getSitePath($path = null) return $result; } + public function getCachePath() + { + return $this->_cache_path; + } + public function get($option, $default = null) { return $this->getConfig()->get($option, $default); diff --git a/code/site/components/com_pages/data/registry.php b/code/site/components/com_pages/data/registry.php index c84e15a5..fbe6d9be 100644 --- a/code/site/components/com_pages/data/registry.php +++ b/code/site/components/com_pages/data/registry.php @@ -34,7 +34,7 @@ protected function _initialize(KObjectConfig $config) $config->append([ 'http' => 'com://site/pages.http.cache', 'cache' => $this->getObject('pages.config')->debug ? false : true, - 'cache_path' => $this->getObject('pages.config')->getSitePath('cache'), + 'cache_path' => $this->getObject('pages.config')->getCachePath(), 'cache_validation' => true, 'namespaces' => array(), ]); diff --git a/code/site/components/com_pages/dispatcher/behavior/cacheable.php b/code/site/components/com_pages/dispatcher/behavior/cacheable.php index 046489cd..1dc54109 100644 --- a/code/site/components/com_pages/dispatcher/behavior/cacheable.php +++ b/code/site/components/com_pages/dispatcher/behavior/cacheable.php @@ -58,7 +58,7 @@ protected function _initialize(KObjectConfig $config) $config->append(array( 'priority' => self::PRIORITY_LOWEST, 'cache' => false, - 'cache_path' => $this->getObject('pages.config')->getSitePath('cache'), + 'cache_path' => $this->getObject('pages.config')->getCachePath(), 'cache_time' => false, //static 'cache_time_shared' => false, //static )); diff --git a/code/site/components/com_pages/http/cache.php b/code/site/components/com_pages/http/cache.php index f72fbd79..348b2683 100644 --- a/code/site/components/com_pages/http/cache.php +++ b/code/site/components/com_pages/http/cache.php @@ -20,7 +20,7 @@ protected function _initialize(KObjectConfig $config) { $config->append([ 'cache' => false, - 'cache_path' => $this->getObject('pages.config')->getSitePath('cache'), + 'cache_path' => $this->getObject('pages.config')->getCachePath(), 'debug' => $this->getConfig('pages.config')->debug ? true : false, ]); @@ -105,7 +105,7 @@ public function send(KHttpRequestInterface $request) public function locateCache($url) { $key = crc32((string)$url); - $file = $this->getConfig()->cache_path.'/resource_'.$key.'.php'; + $file = $this->getConfig()->cache_path.'/response_'.$key.'.php'; return $file; } diff --git a/code/site/components/com_pages/model/cache.php b/code/site/components/com_pages/model/cache.php index 7fd98c6d..74fdd78f 100644 --- a/code/site/components/com_pages/model/cache.php +++ b/code/site/components/com_pages/model/cache.php @@ -23,7 +23,7 @@ protected function _initialize(KObjectConfig $config) { $config->append([ 'type' => 'cache', - 'cache_path' => $this->getObject('pages.config')->getSitePath('cache'), + 'cache_path' => $this->getObject('pages.config')->getCachePath(), 'identity_key' => 'id', ]); diff --git a/code/site/components/com_pages/page/registry.php b/code/site/components/com_pages/page/registry.php index 3bb7ef29..428f231e 100755 --- a/code/site/components/com_pages/page/registry.php +++ b/code/site/components/com_pages/page/registry.php @@ -43,7 +43,7 @@ protected function _initialize(KObjectConfig $config) { $config->append([ 'cache' => $this->getConfig('pages.config')->debug ? false : true, - 'cache_path' => $this->getObject('pages.config')->getSitePath('cache'), + 'cache_path' => $this->getObject('pages.config')->getCachePath(), 'cache_validation' => true, 'collections' => array('pages' => ['model' => 'com://site/pages.model.pages']), 'redirects' => array(), diff --git a/code/site/components/com_pages/resources/config/site.php b/code/site/components/com_pages/resources/config/site.php index eb1137cc..c2bd3078 100644 --- a/code/site/components/com_pages/resources/config/site.php +++ b/code/site/components/com_pages/resources/config/site.php @@ -43,9 +43,9 @@ ], 'com://site/pages.http.cache' => [ - 'cache' => $config['http_resource_cache'], - 'cache_path' => $config['http_resource_cache_path'], - 'debug' => $config['http_resource_cache_debug'], + 'cache' => $config['http_client_cache'], + 'cache_path' => $config['http_client_cache_path'], + 'debug' => $config['http_client_cache_debug'], ], 'com://site/pages.model.cache' => [ 'cache_path' => $config['http_cache_path'],