SimplePie uses a combination of “HTTP Conditional Get” (hereafter known as “HTTPCG”) and caching for optimal efficiency. You can learn more about HTTP Conditional Get at The Fishbowl.
- You tell SimplePie what feed you want to get and where to cache it.
- SimplePie looks to see if the feed is already cached:
- If the cache is fresh use that.
- If there is no cached copy at all, SimplePie will grab and cache the feed.
- If the cache is there but it's old (SimplePie defaults to 60 minutes; configurable with set_cache_duration()), then SimplePie will ask the feed if it has changed since the last time we grabbed it (this is the HTTPCG part).
- If it hasn't changed, we reset the timer on the cache's freshness and keep it for another 60 minutes before checking again.
- If the cache has changed, SimplePie dumps the existing cache (since the cache is just a copy of the data object based on the feed), and grabs a new copy of the feed and uses it.
HTTPCG is a two-part process:
- First, SimplePie knows how to handle HTTPCG-aware feeds. We've got you covered here.
- Secondly, the software that generates the feed needs to be configured to produce HTTPCG-aware feeds. If the software does not understand HTTPCG, then it effectively negates the benefits.
We know that the following software is HTTPCG-aware:
We have absolutely no idea if the following software is HTTPCG-aware:
If you want to utilize the HTTPCG support, but don't want a ton of caching, then set the caching down to 1 minute or a fraction thereof. SimplePie's cache will expire after that minute, and then begin asking the server for a fresh copy every minute from them on.
It takes longer to ask if the feed has changed than it does to simply using the existing (fresh) cache, but it takes less time than fetching the entire feed from scratch. Although most feeds are updated a few times a day, once a day, once a week, or once a month, there are some feeds (such as Digg.com) that update several times an hour. You can set the duration of the cache by using the set_cache_duration() configuration option.
faq/how_does_simplepie_s_caching_http_conditional_get_system_work.txt · Last modified: 2011/03/06 03:56 (external edit)