Work From Home |
|
CACHE YOUR RSS FEEDHow to create a cache file for RSS XML filesIt is well documented that RSS feeds can significantly increase website traffic. Not only do you want primary viewers but have customers come back time and time again because your web page content is continually updated. This is exactly what you need for your job at home or work from home internet business. /* ================================================== Cachemate script to output contents of a RSS XML file and save to your server Author: domain.e-pond.info Created: Sept 2007. Updated: Oct 2007 ================================================== */ $cachefolder="cachemate"; //path to cache directory. No trailing "/". Set dir permission to read/write! // Determine which RSS file to actually fetch // ------------------------------------------------------------- $rssurl= "http://www.e-pond.info/greentreefrogblog/YaBB.pl?action=rss"; $localfile= "rssmate.xml"; //Name cache file based on RSS URL // Do not edit script below // fetchfeed() gets the contents of an external RSS feed, // and saves its contents to the "cached" file on the server // -------------------------------------------------------------- global $rssurl, $localfile; $contents=file_get_contents($rssurl); //fetch RSS feed $fp=fopen("/home/ewcg/public_html/cache/rssweather.xml", "w"); fwrite($fp, $contents); //write contents of feed to cache file fclose($fp); } // outputrsscontent() outputs the contents of a RSS feed using the cached local RSS file // It checks if a cached version of the RSS feed is available, and if not, creates one first. // -------------------------------------------------------------- global $rssurl, $localfile, $cacheminutes; if (!file_exists($localfile)){ //if cache file doesn't exist touch($localfile); //create it chmod($localfile, 0666); fetchfeed(); //then populate cache file with contents of RSS feed } else if (((time()-filemtime($localfile))/60)>$cacheminutes) //if age of cache file great than cache minutes setting fetchfeed(); readfile($localfile); //return the contents of the cache file } Work from Home: More resources...
Further Resources :
|
|
|
Copyright 2007 domain.e-pond.info. All Rights Reserved |
|
Privacy Policy: Your privacy is important to us. No personal information is recorded in the use of this site.
|