Fact #1 : Ajax Caching Is The Same As HTTP Caching It simply obeys the normal HTTP caching rules based on the response headers returned from the server.
The cache: false is used by developers to prevent all future AJAX requests from being cached, regardless of which jQuery method they use. We can use $. ajaxSetup({cache:false}); to apply the technique for all AJAX functions.
ajax({ type: 'POST', url: 'someurl', success: function(result){} }); Then you can abort the request: request. abort();
You can disable caching globally using $.ajaxSetup()
, for example:
$.ajaxSetup({ cache: false });
This appends a timestamp to the querystring when making the request. To turn cache off for a particular $.ajax()
call, set cache: false
on it locally, like this:
$.ajax({
cache: false,
//other options...
});
If you set unique parameters, then the cache does not work, for example:
$.ajax({
url : "my_url",
data : {
'uniq_param' : (new Date()).getTime(),
//other data
}});
Cache-Control: no-cache, no-store
These two header values can be combined to get the required effect on both IE and Firefox
Here is an answer proposal:
http://www.greenvilleweb.us/how-to-web-design/problem-with-ie-9-caching-ajax-get-request/
The idea is to add a parameter to your ajax query containing for example the current date an time, so the browser will not be able to cache it.
Have a look on the link, it is well explained.
you can define it like this :
let table = $('.datatable-sales').DataTable({
processing: true,
responsive: true,
serverSide: true,
ajax: {
url: "<?php echo site_url("your url"); ?>",
cache: false,
type: "POST",
data: {
<?php echo your api; ?>,
}
}
or like this :
$.get({url: <?php echo json_encode(site_url('your api'))?>, cache: false})
hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With