Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Loading ajax content - caching woes

Go to End

8 Posts   3986 Views


Community Member, 712 Posts

11 May 2009 at 2:00pm

Hi all,

I've having an issue with cached content loaded by Ajax.

I'm using jQuery and have disabled browser caching for jQuery ajax requests. I've disabled the SS cache (with HTTP::set_cache_age set to 0). I have cleared the browser cache and rebuilt/flushed. Despite this, content loaded via ajax seems to be coming from a cache. I have to append the ajax query with ?flush=1 to force the response to be updated.

Anyone got a better way?



Community Member, 712 Posts

11 May 2009 at 2:03pm

By the way, the Wiki says that:

"Ajax requests are never cached."

But that is not what I'm seeing.


Community Member, 55 Posts

12 May 2009 at 2:44pm

Edited: 12/05/2009 3:05pm

Are you using Internet Explorer? According to this page:

...IE caches the requests:

Note: Keep in mind that Internet Explorer caches the loaded file, so you should pass some extra random GET parameter to prevent caching if you plan to call this function more than once

Even if not you could try appending a random GET string to the URL you're calling via AJAX and see if that helps.


Community Member, 712 Posts

13 May 2009 at 8:59am

Thanks David, that occurred to me, but I didn't think it would be necessary. I was using FF3 to see the requests.


Community Member, 55 Posts

13 May 2009 at 10:17am

No worries - did that fix it or was there some other solution?


Community Member, 712 Posts

13 May 2009 at 10:20am

Yes, it seems to have done the trick.


Community Member, 2 Posts

9 August 2010 at 4:43am

I have a problem with Ajax in IE 8 Method does not work load. I try to add a URL to a random number

$("#test").load('My_Controller?random=' + Math.random()*99999,data,function(vystup){
                        var obj = jQuery.parseJSON(vystup);

but still nothing. In FF, Safari, Chrome works, but unfortunately Explorer Sun You have some additional advice on how to fix it


Community Member, 50 Posts

26 September 2010 at 1:27am

Hi, would you be able to post some example of your ajax code. I am wanting to do a something like this:

$('input.action').click(function() {
$(this).append('<img src="images/ajax-loader.gif" class="loaderIcon" alt="Loading..." />');

var Name = $('input#name').val();
var Email = $('input#email').val();
var Comments = $('textarea#comments').val();

type: 'post',
url: 'sendEmail.php',
data: 'Name=' + Name + '&Email=' + Email + '&Comments=' + Comments,

success: function(results) {
}); // end ajax

Thanks for any help you can advice me on.