Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to cache my recent comments disqus javascript/ajax code? WordPress

I am using this ajax/javascript code to display recent comments on my wordpress site:


var DisqusRecent = {
init: function( config ) {
this.api_key = config.api_key;
this.forum = config.forum;
this.template = config.template;
this.container = config.container;

this.fetchRecentComments();
},

fetchRecentComments: function() {
$.ajax({
url: "https://disqus.com/api/3.0/forums/listPosts.jsonp?forum="+this.forum+"&related=thread&limit=10&api_key="+this.api_key,
dataType: "jsonp",
context: this,

success: function(results) {
var source = $(this.template).html();
var template = Handlebars.compile(source);
$(this.container).html(template(results));

$('.timeago').timeago();
}
});
}
}

$(function() {
DisqusRecent.init({
api_key: 'myapikey',
forum: 'star-style',
template: '#comments-template',
container: '#comments'
});
});


how can I cache this for 2 hours at a time (disqus only allows so many requests per hour)

Answers (1)

2015-04-24

Reigel Gallarde answers:

This would help you... [[LINK href="http://stackoverflow.com/a/17104536"]]http://stackoverflow.com/a/17104536[[/LINK]]