RSS Caching

Associate
Joined
7 Sep 2003
Posts
1,897
Location
Bo'ness
I used this tutorial http://www.sitepoint.com/article/php-xml-parsing-rss-1-0 to create a simple RSS reader in PHP.

From my understanding of the code, it carries out no caching of the xml file and as such every time somebody
uses my RSS reader it hits the web server the xml file is stored on.

As such I want a way to cache the xml file.
I used cron to run wget in an attempt to download the xml file from the target server but my host has blocked access to wget so I need another method.

Thanks in advance :)
 
That is a pretty old article now. Since you're most likely on PHP5, you can make use of SimpleXML. It makes parsing XML... simple! Seems like a good tutorial here.

On the topic of alternatives to wget, it depends what else you have access to.

There's file_get_contents(), but your host might have disabled fopen wrappers (so you can't get a URL). Same applies to fopen() and fread(), which are the 'old' ways to retrieve a remote file over HTTP.

There's also cURL (http://uk.php.net/manual/en/ref.curl.php), which is my preferred method as it's the most flexible and you can wrap it up into a nice class for reusability. But then that requires access to cURL.

To save the file, you can use fwrite() or file_put_contents() if you're on PHP5.

If your host allows none of these, get a better host :D.
 
Back
Top Bottom