From: Michael Tremer Date: Thu, 11 Oct 2018 12:10:00 +0000 (+0100) Subject: blog: Use upstream cache to cache generated feed X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=04dc362514c1c812928a94b8108a56d9625d4437;p=ipfire.org.git blog: Use upstream cache to cache generated feed Signed-off-by: Michael Tremer --- diff --git a/src/web/blog.py b/src/web/blog.py index 5b7dc4a1..9ce9a6d5 100644 --- a/src/web/blog.py +++ b/src/web/blog.py @@ -31,19 +31,14 @@ class AuthorHandler(base.BaseHandler): class FeedHandler(base.BaseHandler): def get(self): - cache_key = "%s-%s" % (self.request.host, self.request.path) + posts = self.backend.blog.get_newest(limit=50) - # Get feed from cache if possible - feed = self.memcached.get(cache_key) - if not feed: - posts = self.backend.blog.get_newest(limit=50) + # Render the feed + feed = self.render_string("blog/feed.xml", posts=posts, + now=email.utils.formatdate()) - # Render the feed - feed = self.render_string("blog/feed.xml", posts=posts, - now=email.utils.formatdate()) - - # Store in cache for 5min - self.memcached.set(cache_key, feed, 300) + # Allow this to be cached for 5 minutes + self.set_expires(300) # Set correct content type self.set_header("Content-Type", "application/rss+xml")