serverside processing with caching of json result
serverside processing with caching of json result
Hello,
I have created a datatable that could use a caching not having to read the same data from database server and retrieve results to user that been cached 1-2 minutes before.
This is how I check what request been done and filename for cached copy.
[code]
$ajax_page = (isset($_POST) AND is_array($_POST))?implode(',',$_POST):'';
$ajax_cache = '../cache/' . md5($ajax_page) . '.html';
[/code]
What I've found that every request I make to the datatable and sorting by specific sorting column should be the same and I could use cached copy of json data
but it's actually _different_ because of sEcho in the POST request is increasing in every click made.
So every request makes it's own cache file and that's totally useless server time.
If I unset($_POST['sEcho']); before 1st line of code - it's even worse. Sorting isn't happening at all.
This is my configuration:
[code]
"bPaginate": true,
"bProcessing": false,
"bServerSide": true,
"fnServerParams": function (aoData) {
aoData.push( { ...various variables... } );
"iDisplayLength": 25,
"sAjaxSource": "json.php",
"sServerMethod": "POST",
[/code]
Is it possible to change single sEcho posting with GET?
Please, advice.
I have created a datatable that could use a caching not having to read the same data from database server and retrieve results to user that been cached 1-2 minutes before.
This is how I check what request been done and filename for cached copy.
[code]
$ajax_page = (isset($_POST) AND is_array($_POST))?implode(',',$_POST):'';
$ajax_cache = '../cache/' . md5($ajax_page) . '.html';
[/code]
What I've found that every request I make to the datatable and sorting by specific sorting column should be the same and I could use cached copy of json data
but it's actually _different_ because of sEcho in the POST request is increasing in every click made.
So every request makes it's own cache file and that's totally useless server time.
If I unset($_POST['sEcho']); before 1st line of code - it's even worse. Sorting isn't happening at all.
This is my configuration:
[code]
"bPaginate": true,
"bProcessing": false,
"bServerSide": true,
"fnServerParams": function (aoData) {
aoData.push( { ...various variables... } );
"iDisplayLength": 25,
"sAjaxSource": "json.php",
"sServerMethod": "POST",
[/code]
Is it possible to change single sEcho posting with GET?
Please, advice.
This discussion has been closed.
Replies
Replaced
[code]
if ( json.sEcho*1 < oSettings.iDraw )
{
return;
}
[/code]
with
[code]
if ( json.sEcho*1 < oSettings.iDraw )
{
oSettings.iDraw = json.sEcho * 1;
}
[/code]