Browse Source

fix routing cache

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

34
src/server.php

@ -348,19 +348,19 @@ $server->setHandler(
$_uri = isset($matches[1]) ? $matches[1] : ''; $_uri = isset($matches[1]) ? $matches[1] : '';
// File request, get page content // Check for cached results
if ($path = $filesystem->getPagePathByUri($_uri)) if ($content = $memory->get($_uri))
{ {
// Check for cached results $response->setContent(
if ($content = $memory->get($path)) $content
{ );
$response->setContent(
$content
);
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