Monday, January 17, 2011

Disable jQuery cache for AJAX calls

Sometimes, if not most of the time, you don't want to cache your AJAX results. jQuery provides a nice cache: property on the .ajax method, but there are some other very handy AJAX methods in jQuery like .getJson & .load. Fortunately, you can kill all the caching in one swipe with the following:

$.ajaxSetup ({
cache: false

Just simply paste this at the beginning of your function, and any jQuery AJAX calls contained in that function will no longer cache.


No comments:

Post a Comment