For a new site I get content from an external database application (we own it, no hacking). With different parameters I construct an url and the api returns an xml feed. The xml result gets themed in a block. Every block has its own parameters. All in a custom module.

Now today there was a problem with the external database. No big problem, it is all still under development. But that raised an issue: the website stopped loading.

My question: how can I prevent the website stop loading if the external database doesn't respond (quick enough)? Do I need to check response time, or do I ping? Or anything else?

Thanks for thinking with me.

Comments

bboldi’s picture

2 ideas:

1. download the content of the block cron time, store it, and display it from the database
2. write a separate PHP to display content, and load it into an iframe ina block

hanskuiters’s picture

Nice approaches. Not sure about iframe, so I'll focus on the first option. Thanks.

dman’s picture

Yeah, put the external dependency into a cron job and cache it.
It's unlikely you'd be needing to reload a read-only data source every page load. probably very inefficient + fragile

(if you really DO need time-dependent fresh stuff each refresh, then AJAX that requests the data (eg via json) post-load means it won't slow the page load down. Some assembly required to get it all smooth though. )

hanskuiters’s picture

I worked on caching. Not finished yet but looking good allready. Thanks for the help.