cache on browser
cache on browser
lawrance
Posts: 3Questions: 0Answers: 0
I use "sAjaxSource": "data/run_plan.txt" in my code , this file is about 34Mb, I do refresh every 10sec, the problem is that the browser load this file and store it in cache, so after a short time my disk it full, how can I disable the browser caching for this.
This discussion has been closed.
Replies
However, are you sure it is the file that is taking up so much space? 34MB every 10 seconds is a massive amount of data. If there is a leak anywhere, that you are going to very quickly notice that. I'm not aware of any leaks in DataTables at this time, but it is always possible you are seeing the effects of one I don't know about... Try using the Chrome memory tools to see what is going on.
Allan
but it didn't worked, does the datatables override the headers.
it there a flag in datatables that tells "no cache" when loading json file ?
Actually yes - there is... The Ajax request DataTAbles makes by default set's jQuery's `cache` parameter. You'll need to define a custom Ajax request using fnServerData that doesn't enable the cache bypass.
I will make this easier in 1.10...!
Allan
I notice lately that after added fnServerData to override the cache true to false I have 412 (Precondition Failed) ,so I couldn't load the data again
here part of the code
[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!////////////////////////////////////////////include section/////////////////////////////////////////////////!>
Monitor
@import "DataTables-1.9.1/media/css/demo_page.css";
@import "DataTables-1.9.1/media/css/demo_table.css";
@import "css/innerhtml.css" ;
<!--[if gte IE 9 ]><![endif]-->
<!--[if !IE]>--><!--<![endif]-->
///////////////////////////////////////////////////////////Ready///////////////////////////////////////////////////
$(document).ready(function() {
var anOpen = [];
var cbs = [];
var hold = 0 ;
var sImageUrl = "DataTables-1.9.1/examples/examples_support/";
//refresh every 30sec
var oTable = $('#run_plan').dataTable( {
"bProcessing": true,
"bServerSide" : false,
//this save the cookies of the session
"bStateSave": true ,
"sAjaxSource": "data/run_plan.txt",
//added to override the json loader to set cache false
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"cache": 'false',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
[/code]
after adding the fnServerData to set the no cache I couln't load the data I get HTTP 1.1 error 412 (Precondition Failed), can you help please
here part of the code
[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!////////////////////////////////////////////include section/////////////////////////////////////////////////!>
Monitor
@import "DataTables-1.9.1/media/css/demo_page.css";
@import "DataTables-1.9.1/media/css/demo_table.css";
@import "css/innerhtml.css" ;
<!--[if gte IE 9 ]><![endif]-->
<!--[if !IE]>--><!--<![endif]-->
///////////////////////////////////////////////////////////Ready///////////////////////////////////////////////////
$(document).ready(function() {
var anOpen = [];
var cbs = [];
var hold = 0 ;
var sImageUrl = "DataTables-1.9.1/examples/examples_support/";
//refresh every 30sec
var oTable = $('#run_plan').dataTable( {
"bProcessing": true,
"bServerSide" : false,
//this save the cookies of the session
"bStateSave": true ,
"sAjaxSource": "data/run_plan.txt",
//added to override the json loader to set cache false
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": 'json',
"cache": 'false',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
},
[/code]