29Advanced MVCS

In this chapter, we’re going to add to Nerdfeed by adding support for caching and a way to indicate to users which posts have already been read.

Caching the RSS Feed

Each time the user fetches the Apple top songs RSS feed, the BNRFeedStore makes a web service request to Apple’s server. However, it takes time and battery power to make these requests. The data in this feed doesn’t change very often, either. Therefore, it doesn’t make much sense to make the resource-consuming request over and over again.

Instead, the store should save the results of the last request made. If the user tries to reload the feed within five minutes, the store won’t bother making the request and will just return the saved results. This process is known ...

Get iOS Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.