Reputation: 58642
I make a GET to an API, then I got 1000 accounts.
Then, I'm using datatable to rendering my table like this.
The performance seem a bit slow, and I'm trying to improve it. I did some research and I found this, but I don't have access to the database, but I have access to API that return those 1000 accounts as an array.
I'm certainly open to all feedback and suggestions about this process.
Here is my datatable settings
var account_table = $('#account-table').DataTable({
"bPaginate": true,
"processing": true,
"serverSide": true,
"ajax": "scripts/server_processing.php",
"deferLoading": 10,
});
For "ajax": "scripts/server_processing.php", since I am using API, can I just do
"ajax": "https://jsonblob.com/57c08bb2e4b0dc55a4f0eec7" ????
Here is all my sample data : https://jsonblob.com/57c08bb2e4b0dc55a4f0eec7
Upvotes: 0
Views: 115
Reputation: 16015
Most definitely the slowest part about this process is getting those accounts over the web.
Instead of requesting them each time, you could cache them and only request them once every x
amount of time.
pseudo code
function getAccounts() {
if (!cache.has("accounts")) {
// supposedly cache data for 1 hour
cache.set("accounts", getAccountsFromAPI(), 3600);
}
return cache.get("accounts");
}
Upvotes: 1