Monday, March 24, 2014

Disabling Caching on ajax calls using JQuery or javascript

disabling cache of a single call
$.ajax({
url: '@Url.Action("Tasks", "Inbox", new { area = string.Empty })',
data: { userId : '@MyPrincipal.Current.Id' },
cache: false,
type: "GET",
success: function (data) {
$("#numberOfTaskListItems").html(data);
},
dataType: "json"
});
view raw ajax.js hosted with ❤ by GitHub

you can as well enable caching site-wide
$.ajaxSetup({cache: false}});
view raw ajaxSetup.js hosted with ❤ by GitHub