Results 1 to 7 of 7

Thread: gAjax RSS Feeds Displayer not Updating?

  1. #1
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default gAjax RSS Feeds Displayer not Updating?

    1) Script Title:
    gAjax RSS Feeds Displayer
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...sdisplayer.htm
    3) Describe problem:
    I have gotten everything working for this script. However there is a weird problem whereby the RSS feeds on my website will sometime not get updated UNLESS I visit my actual RSS feeds URL.

    Is this intended or is this a bug? If you need, I can provide you my sample website that the RSS feeds reside inside.

    Additional Information:
    I am using a modified javascript version of the RSS feeds displayer done by jscheuer1 at this forum help page, http://www.dynamicdrive.com/forums/s...ad.php?t=67155. The modified version of the javascript basically display the author of the RSS feeds.

    Besides the modified javascript, these are the HTML codes that I used on my website,

    Code:
    <script type="text/javascript" src="http://www.google.com/jsapi?key=API code removed by me">
    </script>
    
    <script type="text/javascript" src="http://shadowinc.zymichost.com/rss/gfeedfetcher.js">
    
    /***********************************************
    * gAjax RSS Feeds Displayer- (c) Dynamic Drive (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    </script>
    
    <style type="text/css">
    
    .labelfield{ /*CSS for label field in general*/
    color:brown;
    font-size: 90%;
    }
    
    .datefield{ /*CSS for date field in general*/
    color:#666666;
    font-size: 100%;
    }
    
    #example1 a{ /*CSS specific to demo 3*/
    color: #D80101;
    text-decoration: none;
    font-weight: bold;
    }
    
    #example1 p{ /*CSS specific to demo 3*/
    margin-bottom: 20px;
    }
    
    </style>
    Code:
    <script type="text/javascript">
    
    var newsfeed=new gfeedfetcher("example1", "example1class", "_new")
    newsfeed.addFeed("Sample", "URL Removed by Me") //Specify "label" plus URL to RSS feed
    newsfeed.displayoptions("datetime author description") //show the specified additional fields
    newsfeed.setentrycontainer("p") //Display each entry as a paragraph
    newsfeed.filterfeed(10, "date") //Show 8 entries, sort by date
    newsfeed.init() //Always call this last
    
    </script>
    Thanks!
    Last edited by ShieldofChaos; 01-29-2012 at 06:47 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The feed is being cached somewhere. Try this where you have the:

    Code:
    newsfeed.addFeed("Sample", "URL Removed by Me" + '?bustcache=' + new Date().getTime()) //Specify "label" plus URL to RSS feed
    add the highlighted. But if your feed URL already has a query string with a ? in it, make that:

    Code:
    newsfeed.addFeed("Sample", "URL Removed by Me" + '&bustcache=' + new Date().getTime()) //Specify "label" plus URL to RSS feed

    If that takes care of the problem we can make it a part of the gfeedfetcher.js script.

    Once that change is made, you will no longer need the highlighted in the on page call. In fact, it should only be done one place or the other, not both. But test it on the page first to see if it works. No sense updating the script if it doesn't help.

    And, since fetching the feed from cache is a feature of this service as provided by Google, it might be best to only do it on the page for feeds that you deem require it. Google is caching the feed to limit its bandwidth exposure. From checking Google Groups on this topic, the cache is supposed to be updated every hour, but respondents claim it can often be much longer.

    So before you do anything, see if it updates on its own after an hour.

    You might also want to check if your server is caching the feed. This solution may or may not help with that.
    Last edited by jscheuer1; 01-29-2012 at 03:52 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ShieldofChaos (02-01-2012)

  4. #3
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thanks alot! I will be trying out and post the result back soon.

    I have a question though, when you said feed URL with a query string, is this a URL that has a query string on it?

    http:// -website url removed by me- /feed/?f=3

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes it is. Use the version with the & symbol for that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #5
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Hi John,

    After two days of testing out, it seems like the code is working. The RSS feeds are updating on their own now.

    Can I continue to use this code at my HTML or should I integrate it into the gfeedfetcher.js? If so, how should I integrate it?

    Thanks for the help!

  7. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    We can update the script. Find the gfeedfetcher.prototype.addFeed function in gfeedfetcher.js and replace it with this one:

    Code:
    gfeedfetcher.prototype.addFeed=function(label, url, bustcache){
    	if(bustcache){
    		bustcache = /\?/.test(url)? '&' : '?';
    		url = url + bustcache + 'bustcache=' + new Date().getTime();
    	}
    	this.feedlabels[this.feedlabels.length]=label;
    	this.feedurls[this.feedurls.length]=url;
    }
    Now, instead of adding '? or '& and bustcache=' + new Date().getTime() you can simply specify true or false as the third parameter when invoking addFeed. So if you had:

    Code:
    newsfeed.addFeed("Sample", "URL Removed by Me" + '?bustcache=' + new Date().getTime()) //Specify "label" plus URL to RSS feed
    or:

    Code:
    newsfeed.addFeed("Sample", "URL Removed by Me" + '&bustcache=' + new Date().getTime()) //Specify "label" plus URL to RSS feed
    Make it:

    Code:
    newsfeed.addFeed("Sample", "URL Removed by Me", true) //Specify "label" plus URL to RSS feed, optional bustcache (true/false)
    If you don't want to bust the cache, use false or put nothing there, not even the comma.

    I should note again that Google is caching these feeds to save on their bandwidth. So it makes sense to only take this sort of measure with feeds that update frequently, and/or that when they do update are presenting time sensitive information.

    If updates are infrequent and done manually, one could edit the addFeed line on an as needed basis, setting the bust cache to true for a few days only when the feed is updated.
    Last edited by jscheuer1; 02-01-2012 at 02:05 PM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ShieldofChaos (02-01-2012)

  9. #7
    Join Date
    Jan 2012
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thanks John!

    Will put them in my JS when I am doing the finalization of my website coding.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •