jQuery: Disable (browser) cache for all AJAX requests

Here is a small JavaScript code snippet that uses jQuery’s .ajax() function to disable the (client side browser) cache for all subsequent jQuery AJAX calls (note that caching is enabled by default for all data types except script and jsonp):

  cache: false

To enable caching for a special AJAX request one can override the settings be explicitly defining the cache option when calling jQuery’s .ajax():

  url: [...],
  cache: true,
  success: function(){ [...] },

One response to “jQuery: Disable (browser) cache for all AJAX requests”

Leave a Reply

Your email address will not be published. Required fields are marked *