Why RSS runs slowly?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
morris520
Forum Commoner
Posts: 60
Joined: Thu Sep 18, 2008 8:56 pm
Location: Manchester UK

Why RSS runs slowly?

Post by morris520 »

Hi, just a general question uncertain.

I am reading a rss feed from my blog, displaying the topics on index page. But then my index page takes longer to load? why?

Just thinking can AJAX help?

My original design was to display the topics on a pop-out layer when user clicks a button.

Please give some general advice to avoid the time on loading. Thanks
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Why RSS runs slowly?

Post by Benjamin »

Is it pulling the feed from a remote server, your database or from a cache?
User avatar
morris520
Forum Commoner
Posts: 60
Joined: Thu Sep 18, 2008 8:56 pm
Location: Manchester UK

Re: Why RSS runs slowly?

Post by morris520 »

I think my code reads from the remote server, e.g. bbc server.

Time maybe spent on loading data from it.

If not possible to reduce the time can I write a loading bar or similar to tell user when the loading finishes ?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Why RSS runs slowly?

Post by Benjamin »

It would probably be easiest for you to save the feeds locally and serve them from your server. You can refresh them every 10 minutes or so.
User avatar
morris520
Forum Commoner
Posts: 60
Joined: Thu Sep 18, 2008 8:56 pm
Location: Manchester UK

Re: Why RSS runs slowly?

Post by morris520 »

This is the code I called when the button on index page is clicked. Is this called locally?

Code: Select all

 
function writePost(){
    $myMsnRss = 'http://morris520blog.spaces.live.com/feed.rss';
    //$titleArray[] = array();
 
    $doc = new DOMDocument;
    $doc->load($myMsnRss);
 
    for($i=1;$i<=$doc->getElementsByTagName('title')->length;$i++)
    {
        $topic = $doc->getElementsByTagName('title'); 
        $link = $doc->getElementsByTagName('link'); 
        $titleArray[$topic->item($i)->nodeValue] = $link->item($i)->nodeValue;
        //echo 'content: '.$topic->item($i)->nodeValue."<br/>";
    }
    
    return $titleArray;
}
 
Post Reply