It looks like if I load dynamic content using $.get()
, the result is cached in browser.
Adding some random string in QueryString seems to solve this iss
If you are using .net ASP MVC, disable the caching on the controller action by adding the following attribute on the end point function:
[OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)]
add header
headers: {
'Cache-Control':'no-cache'
}
The following will prevent all future AJAX requests from being cached, regardless of which jQuery method you use ($.get, $.ajax, etc.)
$.ajaxSetup({ cache: false });
append Math.random()
to the request url
Basically just add cache:false;
in the ajax where you think the content will change as the progress go on. And the place where the content wont change there u can omit this. In this way u will get the new response every time
Following the documentation: http://api.jquery.com/jquery.ajax/
you can use the cache
property with:
$.ajax({
method: "GET",
url: "/Home/AddProduct?",
data: { param1: value1, param2: value2},
cache: false,
success: function (result) {
// TODO
}
});