I serve ads on the Drudge Retort using Blogads, a great ad broker that occasionally has trouble serving the ads. When this happens, pages on the Retort load more slowly because they can't fetch a Javascript program and CSS stylesheet required by Blogads.
I decided to fix this problem by writing Cache Remote File, a PHP script that performs three functions:
- Save a cached copy of a remote file
- Display the cached copy for 10 minutes before requesting the file again
- Display the cached copy when the remote server is offline or slow
The script will give up trying to load the remote file after three seconds, which keeps it from hanging when the remote server is having difficulties. It can be customized to load any URL of any content type and requires PHP 4 or higher with cURL support. I've released it under the GPL. Let me know if you have any problems with it or can improve the script.
