Did some work on becontrary.com today. The front page was a little dull and had a bounce rate of 49.8% according to Google Analytics, which means that almost half of the visitors that land there don't go any further. Previously the front page just displayed a news feed and some recent arguments and comments, I change it so that the feed in the main column aggregates the content from the debates so that in addition to news, it also displays new debate topics and arguments. The result is that it the front page should contain much more interesting content that will tempt visitors to explore the site.

I also made the BeContrary aggregated content available as an RSS feed, which makes it very easy for me to keep an eye on activity in the site. Hopefully it should be entertaining for visitors as well. Turbogears makes it laughably simple to add news feeds with the FeedController class. You simply derive from it and supply a method that returns the feed content. The controller does the work of producing the XML and serving it with CherryPy.

Because the changes would increase database access, I wrote a caching decorator for methods that return site content which doesn't need to update very often. If the decorated method is called within a definable period of time, the decorator returns a cached copy of the return value rather than building it again. Using this decorator I was able to reduce the database calls for the front page to zero for most requests (it updates every half an hour). This should come in handy if I get Slashdotted, Reddited or Dugg. Come to think of it, I could use the cache decorator on most of the site content. Even if the cache time was set to one minute it would be worthwhile for serious traffic. If I were to get 10 requests in a minute, it would reduce database access to one tenth! I'll probably blog the decorator at some point.

I seem to be finding a lot of time for my blog and hobby projects lately, because my TV broke! Rest in peace, my widescreen friend.

Update: I blogged the decorator code.
This blog post was posted to It's All Geek to Me on Saturday October 13th, 2007 at 3:44PM
 

1 Response to "Caching Aggregated News Feeds"

  • October 13th, 2007, 6:18 p.m.

    I'd definitely be interested in seeing that cache decorator. It's one of those things that I wish was built-in to TG - as it's such a quick easy performance enhancer.

Leave a Comment

You can use bbcode in the comment: e.g. [b]This is bold[/b], [url]http://www.willmcgugan.com[/url], [code python]import this[/code]
Preview Posting...
Previewing comment, please wait a moment...

My Tweets

Will McGugan

My name is Will McGugan. I am an unabashed geek, an author, a hacker and a Python expert – amongst other things!

Search for Posts
Possibly related posts
Tags
Popular Tags
 
Archives
2010
 
Recent Comments
This is very true, i believe that people need to be able to use a domain if they register it, ...
Hehe Thats a good tatoo idea ;) Have a nice day Joel
- Joel Shapiro on Powered by Ubuntu
Weirdly enough i am a junior dev on an internship. I am @ work and i was way too bored/out ...
I love the idea of locidesktop, and even more the minimal UI. Hope you'll keep it up!
Many thanks! I tried several solutions but the only one that worked was yours.
 
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan