Server side processing and client side caching

Server side processing and client side caching

fastbikefastbike Posts: 14Questions: 0Answers: 0
edited April 2010 in General
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 ?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi fastbike,

    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
  • fastbikefastbike Posts: 14Questions: 0Answers: 0
    edited April 2010
    Thanks
    I'll look out for it.
  • gutzoftergutzofter Posts: 58Questions: 0Answers: 0
    I don't know if this will help

    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
  • fastbikefastbike Posts: 14Questions: 0Answers: 0
    Thanks - although as the author points out it is not a true GUID :(
  • gutzoftergutzofter Posts: 58Questions: 0Answers: 0
    @fastbike,

    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?
  • fastbikefastbike Posts: 14Questions: 0Answers: 0
    Yep, my solution works. Although I was pointing out, and Allan agreed, that it would be nice to have this out of the box.
This discussion has been closed.