Skip to content

Commit

Permalink
Cache page content
Browse files Browse the repository at this point in the history
  • Loading branch information
OldStarchy authored Sep 30, 2021
1 parent a7e9fb8 commit 698c33a
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/SeoObjectExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -811,16 +811,22 @@ public function getNumCharsTitle() {
*/
public function getPageContent()
{
$session = [];
if (Controller::has_curr()) {
$session = Controller::curr()->getRequest()->getSession();
}
$response = Director::test($this->owner->Link(), [], $session);
static $cache = null;

if ($cache === null) {
$session = [];
if (Controller::has_curr()) {
$session = Controller::curr()->getRequest()->getSession();
}
$response = Director::test($this->owner->Link(), [], $session);

if (!$response->isError()) {
return $response->getBody();
if (!$response->isError()) {
$cache = $response->getBody();
} else {
$cache = '';
}
}

return '';
return $cache;
}
}

0 comments on commit 698c33a

Please sign in to comment.