Server side processing and client side caching
Server side processing and client side caching
I'm finding that IE7 is caching the results of calls to the server. This does not appear to be happening in FF.
One work around is to add an extra parameter to the function that handles fetching server data
[code]
...
"fnServerData": getServerData
...
[/code]
and
[code]
function getServerData( sSource, aoData, fnCallback ) {
// add an anti caching parameter
aoData.push( { "name": "nocache", "value": Math.random() } );
$.getJSON( sSource, aoData, function (json) {
// tell DataTables to get on with it
fnCallback(json)
});
}
[/code]
Is there a built in setting to tell the datatable to always add a unique value to prevent client side caching ?
One work around is to add an extra parameter to the function that handles fetching server data
[code]
...
"fnServerData": getServerData
...
[/code]
and
[code]
function getServerData( sSource, aoData, fnCallback ) {
// add an anti caching parameter
aoData.push( { "name": "nocache", "value": Math.random() } );
$.getJSON( sSource, aoData, function (json) {
// tell DataTables to get on with it
fnCallback(json)
});
}
[/code]
Is there a built in setting to tell the datatable to always add a unique value to prevent client side caching ?
This discussion has been closed.
Replies
The other method that also works is to have fnServerData use POST rather than get. However, at this time there is no built in method to stop this from happening. I've just added it to my to-do list for addition to the next release, as this can be very annoying in IE.
Regards,
Allan
I'll look out for it.
http://blog.shkedy.com/2007/01/createing-guids-with-client-side.html
[code]
function generateGuid()
{
var result, i, j;
result = '';
for(j=0; j<32; j++)
{
if( j == 8 || j == 12|| j == 16|| j == 20)
result = result + '-';
i = Math.floor(Math.random()*16).toString(16).toUpperCase();
result = result + i;
}
return result
}
[/code]
Should help I think
The only thing to do is use a hack or you could keep a table based on time/date and increment entries (more hack) or change the response headers coming from your server to explicitly state no caching.
http://greenash.net.au/posts/thoughts/an-ie-ajax-gotcha-page-caching
Does even your solution even work?