I happened to notice in my application that the copy_csv_xls_pdf.swf is getting called three times when datatables/tabletools are invoked. I put together a jsfiddle which (sometimes) illustrates the issue:
The same behavior can be observed from the TableTools documentation:
This behaviour is particularly problematic because the intial load of the file doesn't seem to be cached by the browser for the subsequent loads during that same request.
There seems to be a request to this file for each button that is "powered" by the SWF.
Still, why is this file getting loaded multiple times? Is it necessary? How can it be prevented (while still providing the same functionality)?
Ignore the following unnecessary code....
...which is only provided so that SO will allow me to include the link to the jsfiddle:
$('#browser_data').dataTable({
"bPaginate": false,
"bAutoWidth": false,
"bLengthChange": false,
"sDom": "<'row-fluid'<'span6'f><'span6'<'pull-right'T>>r>t",
"oTableTools": {
"aButtons": [ "copy", "xls", "pdf" ],
"sSwfPath": "http://datatables.net/release-datatables/extras/TableTools/media/swf/copy_csv_xls_pdf.swf"
}
});
Google Chrome
Here is a snippet of the request headers -- the headers are the same whether I hard-refresh or just refresh:
:host:datatables.net
:method:GET
:path:/release-datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf
:scheme:https
:version:HTTP/1.1
accept:*/*
accept-encoding:gzip, deflate, sdch
accept-language:en-US,en;q=0.8,sw;q=0.6
cache-control:no-cache
cookie:
Do you see cache-control:no-cache
? This seems to suggest that caching is explicitly turned off when making these requests. Every refresh shows status 200 for each request ... never do I see 304.
And as far as the 304 statuses in your screenshot are concerned it's important that they are 304, 304, 304 and not 200, 304, 304. This would suggest that each request is unique in some way other than URL-wise and therefore each has to be explicitly cached. Let's see if that's a correct hypothesis ....
Mozilla Firefox
Here is the procedure I followed to run some tests:
Here are the results -- one status for each button:
Considering the buttons are not exactly the same, even though the .swf
URL is the same, wouldn't this make perfect sense? The same URL giving rise to a different button each time! Could there be some sort of signature to differentiate the requests for each button? This is the behavior of dynamic content -- same URL different content.
One final test:
I turned off caching -- set cache limit to 0 and the results are:
Conclusions