Well, I'm trying to learn about caching in PHP and this is my first attempt at it. The item level of the rss feed seems to have vanished by the time it gets to my parser, which is driving me crazy. What's causing this?



//cache requesting
function request_cache($url, $dest_file, $timeout=13200) {
  if(!file_exists($dest_file) || filemtime($dest_file) < (time()-$timeout)) {
    $data = file_get_contents($url);
    $tmpf = tempnam('/tmp','YWS');
    file_put_contents($tmpf, $data);
    rename($tmpf, $dest_file);

//query loading with cache
$q = 'http://pipes.yahoo.com/pipes/Zmn2To672xGonTsUfOgC8A/run?_render=rss';
$tmp = '/tmp/yws_pipe_'.md5($q);
request_cache($q, $tmp, 13200);
$xml = simplexml_load_file($tmp, 'cNode') or die ('Unable to load XML file!'); 

//work around class for early PHP 5 bugs in DOM support. 

class cNode extends SimpleXMLElement {
    function getName() {
        return dom_import_simplexml($this)->nodeName;

    function getType() {
        return dom_import_simplexml($this)->nodeType;

//actual parsing and adding of div containers. 

echo '<div id="whead">This site</br> through Flickr </div>';
echo '<div id="wgallery">';

foreach($xml->children() as $child){
		       	foreach($child->item as $grandchild){
				$link = $grandchild->link;
				$image = $grandchild->description;
				echo '<div class="cell" align="center"><a href="'. $link. '">'. $image. '</a></div>';
echo '</div>';
echo '<div id="wfoot"></div>';