From 931b4d4670df9a15448e90bca12bb34fce445115 Mon Sep 17 00:00:00 2001 From: Nicholas Sorokin Date: Fri, 1 Oct 2021 19:31:08 +0930 Subject: [PATCH] Cache page content hubertusanton/silverstripe-seo#40 --- code/SeoObjectExtension.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/SeoObjectExtension.php b/code/SeoObjectExtension.php index a3e1f7c..f6c1465 100644 --- a/code/SeoObjectExtension.php +++ b/code/SeoObjectExtension.php @@ -681,12 +681,16 @@ protected function findLayout() { * */ public function getPageContent() { + static $cache = null; - Config::inst()->update('SSViewer', 'theme_enabled', true); - $rendered_layout = $this->RenderLayout(); - Config::inst()->update('SSViewer', 'theme_enabled', false); - return $rendered_layout; + if ($cache === null) { + Config::inst()->update('SSViewer', 'theme_enabled', true); + $rendered_layout = $this->RenderLayout(); + Config::inst()->update('SSViewer', 'theme_enabled', false); + $cache = $rendered_layout; + } + return $cache; } }