From de96fb60de756862d740722886412bdb3f070d96 Mon Sep 17 00:00:00 2001 From: rdalverny Date: Sat, 22 Jan 2022 22:01:35 +0100 Subject: Also cache Atom feed --- public/admin/subscriptions.php | 4 ++-- public/feed/index.php | 26 ++++++++++++++++++-------- public/index.php | 1 - 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/public/admin/subscriptions.php b/public/admin/subscriptions.php index 236ac46..a46260e 100755 --- a/public/admin/subscriptions.php +++ b/public/admin/subscriptions.php @@ -24,7 +24,7 @@ if (isset($_POST['upload']) && OpmlManager::save($newOpml, $opmlFile); Cache::setStore($PlanetConfig->getCacheDir() . '/'); - Cache::prune("html"); + Cache::prune('html'); } elseif (isset($_POST['opml']) || isset($_POST['add'])) { // Load old OPML $oldOpml = OpmlManager::load($opmlFile); @@ -84,7 +84,7 @@ if (isset($_POST['upload']) && OpmlManager::save($newOpml, $opmlFile); Cache::setStore($PlanetConfig->getCacheDir() . '/'); - Cache::prune("html"); + Cache::prune('html'); } header("Location: index.php"); die(); diff --git a/public/feed/index.php b/public/feed/index.php index 90ce907..718b14c 100644 --- a/public/feed/index.php +++ b/public/feed/index.php @@ -1,6 +1,5 @@ loadOpml($PlanetConfig->getOpmlFile()) == 0) { header('Content-Type: text/xml; charset=utf-8'); @@ -8,13 +7,20 @@ if ($Planet->loadOpml($PlanetConfig->getOpmlFile()) == 0) { exit; } -$Planet->loadFeeds(); -$items = $Planet->getItems(); -$limit = $PlanetConfig->getMaxDisplay(); -$count = 0; +$cache_duration = $PlanetConfig->getOutputTimeout(); +Cache::$enabled = ($cache_duration > 0); +Cache::setStore($PlanetConfig->getCacheDir() . '/'); -header('Content-Type: text/xml; charset=UTF-8'); -echo ''; + +if (!OutputCache::Start('html', 'atomfeed', $cache_duration)) { + $items = $Planet->getFeedsItems(); + $limit = $PlanetConfig->getMaxDisplay(); + $count = 0; + + $updatedAt = date_format(date_create('now', new DateTimeZone('UTC')), DateTimeInterface::ATOM); + + header('Content-Type: text/xml; charset=UTF-8'); + echo ''; ?> <?=htmlspecialchars($PlanetConfig->getName())?> @@ -22,7 +28,7 @@ echo ''; getUrl()?> - + getName())?> @@ -41,3 +47,7 @@ echo ''; + diff --git a/public/index.php b/public/index.php index 0a0de38..be28bed 100755 --- a/public/index.php +++ b/public/index.php @@ -1,6 +1,5 @@ ' . _g('You might want to install moonmoon.') . '

'); -- cgit v1.2.1