Browse Source

fix routing cache

main
ghost 9 months ago
parent
commit
525c7e89fa
  1. 22
      src/server.php

22
src/server.php

@ -348,11 +348,8 @@ $server->setHandler(
$_uri = isset($matches[1]) ? $matches[1] : ''; $_uri = isset($matches[1]) ? $matches[1] : '';
// File request, get page content
if ($path = $filesystem->getPagePathByUri($_uri))
{
// Check for cached results // Check for cached results
if ($content = $memory->get($path)) if ($content = $memory->get($_uri))
{ {
$response->setContent( $response->setContent(
$content $content
@ -361,6 +358,9 @@ $server->setHandler(
return $response; return $response;
} }
// File request, get page content
else if ($path = $filesystem->getPagePathByUri($_uri))
{
// Define base URL // Define base URL
$reader->setMacros( $reader->setMacros(
'~URL:base~', '~URL:base~',
@ -506,7 +506,7 @@ $server->setHandler(
// Cache results // Cache results
$memory->set( $memory->set(
$path, $_uri,
$content $content
); );
@ -521,16 +521,6 @@ $server->setHandler(
// File not found, request directory for minimal navigation // File not found, request directory for minimal navigation
else if ($directory = $filesystem->getDirectoryPathByUri($_uri)) else if ($directory = $filesystem->getDirectoryPathByUri($_uri))
{ {
// Check for cached results
if ($content = $memory->get('/'))
{
$response->setContent(
$content
);
return $response;
}
// Init reader // Init reader
$reader = new \Yggverse\Gemini\Dokuwiki\Reader(); $reader = new \Yggverse\Gemini\Dokuwiki\Reader();
@ -666,7 +656,7 @@ $server->setHandler(
// Cache results // Cache results
$memory->set( $memory->set(
'/', $_uri,
$content $content
); );

Loading…
Cancel
Save