Activity › Forums › Salesforce® Discussions › How do we cache server side data on lightning component?
-
How do we cache server side data on lightning component?
Posted by Anjali on September 21, 2018 at 1:39 PMHow do we cache server side data on lightning component?
Parul replied 7 years, 7 months ago 3 Members · 2 Replies -
2 Replies
-
Hi,
The component calls a server method
The framework checks if the response is available in the cache
The response is available in the cache and needs to be refreshed (cached response age > refresh age)
The framework calls the action callback function providing the cached response
The framework calls the server method to get a fresh response
The server returns the response
The framework updates the cache with the new response
If the server response is different from the cached response, the framework calls the action callback function for the second time with the updated responseThanks
- [adinserter block='9']
-
Adding some points:
1. Using Server-Side Controller:
You need to use LIMIT and OFFSET values in SOQL query
You need to make the server-side call to retrieve the data for every page, which is pretty expensive (will come to this part later**)
You can never show total page count as you are not fetching the total record at once or you are not sure how many records will be returned
Better solution if you are dealing with many records as you can fetch n number of records.
Data loading will be same in almost all the pagesNote**: To make component performance faster, I am using “Action.setStorable()” method, which will cache the data on client side and will improve component performance drastically.
Thanks
Log In to reply.