Muse Reader James Asks:
I have the following situation. I need to run a .cfm page that has a redirect in it to another server that serves Joomla pages. I need to find a way to test and see if that server is down or not serving pages. If it is down or not serving pages, I want to stop the redirect to that server and send the user to a page on my server. Any suggestions?
This is fairly easily accomplished using CFHTTP. When the page loads you can hit your Joomla server with a CFHTTP call and a timeout value. You could, for example, use code like this:
But you probably don't want to do this for the simple fact that it doubles the amount of traffic your Joomla server will experience. For every request to your page you will generate a "test" request as well as the request that you "forward". A better solution would be to create a scheduled task that checks the page every minute or 2 and sets an application variable like so:
Then of course in your main page you only need to check your application variable like so:
Of course this still affects traffic but potentially much less so. If you are concerned about stats another approach would be to create a page on the server that is only for your test request. I would suggest that it be a page that includes a selection from the database since that is one of the items that often "brings down" a server. And of course my readers also have additional suggestions.