NeonCam Dollars
Surfers - Webmasters - Cam Models - Studios

How to cache an XML feed

This is another short tutorial about XML feeds. The first one is about parsing an XML feed. If you haven't read it yet, or would like to recap about how to parse an XML feed, now would be a good time to go through it. All the feeds in this tutorial are from the live web cam site Neon Cams, but whatever you learn in this tutorial, you can apply to almost any XML feed, including RSS feeds that are a form of XML. The feeds and images are all taken from Neon Dollars. Neon Dollars is the webmaster affiliate program for Neon Cams and well worth a look if you have any sort of web cam traffic.

What is covered in this tutorial

From the parsing and XML feed tutorial we know what to do with a feed, how to change it into something that we can use, and how to output it so our surfers can see the data held within it. This is all well and good if the XML feed is fairly small, but what if our XML feed contains a lot of data, say hundreds or even thousands of entries. Pulling in a raw XML feed from another site each time slows down the page loading time, and puts more load on your server. What we are going to do through this short tutorial is cache a local copy of the XML feed on your server so your files can read the data quicker and deliver your pages faster.

Important files for this tutorial

There are going to be 3 important files used for this tutorial, and if you plan on following the examples you will need all of them. The first is the same one as we used in the parsing and XML feed tutorial, so you may already have the clsParseXML.php file. If you do, you will not need it again.
The first new file that we are going to use is cacheFile.php which is a very small file that will cache our XML feed for us. The last new file is called allCache.txt which our cacheFile.php file should make for us automatically.

If you click the file names you will download the same files that are used in this tutorial. They are also all listed at the end of this short tutorial.

Caching The File
Neon Cam Join the Neon Cams affiliate program and get $150 sign up bonus