Feed cache fallback - A feed could not be found

Trying to refactor a feed plugin to fallback on cache if source is unavailable (ex: for maintenance).

Started using fetch_feed($url); which affords more flexibility in terms of cache. But unsure of how to structure the fallback.

Topic simplepie feed cache Wordpress

Category Web


Sounds like you are looking at it from a very low layer POV. fetch_feed provides caching so you will not need to wait for a response on possibly every page load. Therefor, as long as there is a cache you are unlikely to even want a message to be sent and obviously you are not handling any actual result. It is unlikely that you will want to hurt your server with a faster refresh rate just to be able to properly detect the conditions on the other side.

What you should do is to handle the situation of not getting a reply, which is probably equal to empty feed, to supply the defaults you want.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.