diff --git a/modules/cms/classes/Theme.php b/modules/cms/classes/Theme.php index 10fce24dd..2bc1a883e 100644 --- a/modules/cms/classes/Theme.php +++ b/modules/cms/classes/Theme.php @@ -48,6 +48,7 @@ class Theme const ACTIVE_KEY = 'cms::theme.active'; const EDIT_KEY = 'cms::theme.edit'; + const CONFIG_KEY = 'cms::theme.config'; /** * Loads the theme. @@ -336,7 +337,16 @@ class Theme return $this->configCache = []; } - $config = Yaml::parseFile($path); + try { + $config = Cache::rememberForever(self::CONFIG_KEY, function() use ($path) { + return Yaml::parseFile($path); + }); + } + catch (Exception $ex) { + // Cache failed + $config = Yaml::parseFile($path); + } + /** * @event cms.theme.extendConfig @@ -455,6 +465,8 @@ class Theme $contents = Yaml::render($values); File::put($path, $contents); $this->configCache = $values; + + self::resetCache(); } /** @@ -484,6 +496,7 @@ class Theme Cache::forget(self::ACTIVE_KEY); Cache::forget(self::EDIT_KEY); + Cache::forget(self::CONFIG_KEY); } /**