[solved] How do I disable the cache busting query parameter that DataTables attaches?

[solved] How do I disable the cache busting query parameter that DataTables attaches?

elijahelijah Posts: 1Questions: 0Answers: 0
edited July 2011 in DataTables 1.8
I've inherited a web app that makes use of DataTables and unfortunately I'm not very knowledgeable with regards to its API and idiomatic usage.

My problem is that every time my page that displays data tables is refreshed it makes a call to its data source here:
/merchants/spreadsheets?_=1310422129834

with the parameter _=xxxxxxxxxxx changing on every call. I realize the need to always get fresh data, but it is preventing me from doing HTTP caching.

I've verified using a Javascript debugged that the cache busting parameter is not getting added from the application, but is rather getting entered somehow from the datatables code.

How do I disable this functionality?

The data table is created as so:
[code]
// Set up the data table.
$('#spreadsheets-list-table').dataTable({
sAjaxSource: spreadsheetsUrl,
bJQueryUI: true,
sPaginationType: 'full_numbers',
aLengthMenu: [10, 25],
bProcessing: true,
fnRowCallback: function(element, data, index) {
$(element).click(function() {
window.location = spreadsheetsUrl + '/' + data[0];
});
return element;
},
aoColumns: [
hiddenColumn, // Spreadsheet ID
hiddenColumn, // Organization ID
nameColumn, // Organization Name
null, // Project Name
actionColumn, // File Action
fileSourceColumn, // File Source
hiddenColumn, // Hold Status
statusColumn, // Status
rowsColumn, // Number of Rows in Spreadsheet
nameColumn, // Assigned To
dateColumn // Date Uploaded
],
aaSorting: [[7, 'desc']] // Date Uploaded
});
[/code]

Apparently, the above call was being done as a call back. So, I added the following snippit and the problem was solved:

[code]
/* Prevent data tables from adding a cache-busting timestamp to each call */
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some data to send to the source, and send as 'POST' */
aoData.push( { "name": "data_type", "value": "json" } );
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
[/code]
This discussion has been closed.