Darren Ferguson - Umbraco, Dev, PhoRSS

Saturday, June 14, 2008

Feed Cache package for Umbraco

Filed under: Umbraco - by Darren Ferguson @ 7:08 PM

I've created an umbraco package that will cache XML feeds - or any other http URL - to disk on your web server. Click here to download the package

The idea came about as a lot of people are displaying feeds on their web pages - flickr feeds, twitter etc. In Umbraco you can cache marcos that read external URLs, but ultimately when the cache expires one user will have to take the hit of requesting this external URL as part of their page download. If the third party server is down - which twitter frequently is - then this can result in a hefty wait until the request times out.

Instructions for using the package are in the readme prior to installation so be sure to read this before proceeding with the install.

Questions, comments, feature requests etc are all welcome.

9 comment(s) for “Feed Cache package for UmbracoComments RSS

  1. Douglas Robar says:
    Douglas Robar
    This seems a very nice solution to a not-uncommon problem.

    Two questions, though. What happens with your package if the third-party server is down? Does it just time out and the old/previously-cached xml file get used?

    And (just so I'm 100% clear on this)... your package simply creates the xml files on my webserver's disk, and I will need to use GetXmlDocumentByUrl() to retrieve it from my local server and display it the output appropriately. Right?

    cheers,
    doug.
  2. Darren Ferguson says:
    Darren Ferguson
    Hi Doug,

    If for any reason the feed can't be retrieved from the external server the error message will be logged and the previous version of the cached feed will still be available.

    As for the second question, you are correct. The feed is simply written to disk. You'll need to read and render the feed somehow in order to display it.

    Hope this helps.
    Darren.
  3. Douglas Robar says:
    Douglas Robar
    Sounds great. I might have a project coming up that could really use this!

    Thanks for sharing!

    cheers,
    doug.
  4. Kenneth Solberg says:
    Kenneth Solberg
    Thanks for sharing Darren! This is a very useful package.
  5. Warren Buckley says:
    Warren Buckley
    Hiya Darren,
    We need to talk about some integration with my twitter package would be good - however not sure about dependencies?!

    //Warren
  6. Thomas Kahn says:
    Thomas Kahn
    Could this be used for caching content that is consumed via a web service? It would be great to be able to show cached content if the web service was unavailable.

    Just a thought...
  7. Darren Ferguson says:
    Darren Ferguson
    @warren - sure let's have a chat on MSN sometime. If your package allows you to specify a feed URL then I guess it should work already. Just specifying the feed URL as file:///c:/path/to/feed.xml should be fine.

    @Thomas - No reason why it couldn't do that. At the moment only GET is supported, so would have to extend it slightly to be able to post a request. Let me know if you are interested and we can discuss, maybe on the forum.
  8. Soeren Sprogoe says:
    Soeren Sprogoe
    Brilliant idea, Darren!

    However there's one thing I don't get: Why the need to configure caching of each individual file?

    Why not do it in the following way instead:

    Call a URL with the feed as parameter each time it needs to be accessed. Fx. www.yoursite.com/feedcache.aspx?feed=http://www.feed.com/rss.xml

    The feedcache loads the feed in to memory fx. for the next 24 hours or so in the system.cache. Every time the feed is requested via feedcache.aspx, the memory version is returned.

    Then you can have a scheduled task running fx. every hour that goes through all feeds loaded into memory and refreshes them if possible.

    This would eliminate the need for the configuration file, and make it much more dynamic.
  9. Darren Ferguson says:
    Darren Ferguson
    Hi Soeren,

    Initially I thought about having a scheduled task for each feed and just passing the URL as a parameter as you suggest.

    I'm going to put the source into codeplex at some point so it would be really easy to modify and work as you suggest.

    If you'd like the code, just drop me a mail.

    Darren.

Leave a comment

Darren Ferguson - Umbraco, Dev, Pho is published with Umbraco 3.0.5