From c102123dc902b855842d3e9942b4629abba83ebb Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Wed, 22 Oct 2014 11:35:12 +0200 Subject: add caching --- service/feedservice.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'service/feedservice.php') diff --git a/service/feedservice.php b/service/feedservice.php index 872f05ef8..6ecf543b1 100644 --- a/service/feedservice.php +++ b/service/feedservice.php @@ -192,14 +192,25 @@ class FeedService extends Service { } try { - list(, $items) = $this->feedFetcher->fetch( - $existingFeed->getUrl(), false); + list($fetchedFeed, $items) = $this->feedFetcher->fetch( + $existingFeed->getUrl(), + false, + $existingFeed->getLastModified(), + $existingFeed->getEtag() + ); + + // if there is no feed it means that no update took place + if (!$fetchedFeed) { + return $existingFeed; + } // update number of articles on every feed update if($existingFeed->getArticlesPerUpdate() !== count($items)) { $existingFeed->setArticlesPerUpdate(count($items)); - $this->feedMapper->update($existingFeed); } + $existingFeed->setLastModified($fetchedFeed->getLastModified()); + $existingFeed->setEtag($fetchedFeed->getEtag()); + $this->feedMapper->update($existingFeed); // insert items in reverse order because the first one is // usually the newest item -- cgit v1.2.3