Ajax can make some of our web services more responsive, but occasionally this becomes less responsive when certain contents were cached somewhere in the middle of the server and our client side, this could go really bad if your site application requires frequent update. It’s always beyond our control to adjust the cache settings.
The work around is really easy, Mootools core comes with some really handy shortcuts that could make this problem a piece of cake.
The two shortcuts we need here are $time and $random, $time returns the current time and $random returns a random number in a given range.
suppose you have the ajax url like the one below:
url: demo_path + 'data.php,
all you need to do to prevent the caching is to modify it to:
url: demo_path + 'data.php?a=' + $time()+$random(1, 10000),
Time always updates and a random number between 1 to 10000 could make the url more unique each time the url’s called, this simple modification will trick the browser to think it’s retrieving a new file each time but actually the same file but with different content!
Hope this works!





















































