Hello Lightning Experts,

How to implement custom caching in Client Side for Lightning. Is HTML 5 Web Storage is right option for this?

Use Case: Based on the service address, show the service partner details, allow user to select partner. After the selection of the partner navigate the user to next screen and allow him to Time Slot.

Current Design: 1) we have developed a custom lightning component, Once the user enters the service address call the external system to retrieve partner details and time slots. 2) External System will provide around 15-25 partners List of data and each partner will have 5-15 time slots in the below format.

Below is just a sample format.

  "partners": [
    { "name":"p1", "models":[ "10AM-11AM", "12PM-1PM", "1AM- 3AM" ] },
    { "name":"p2", "models":[ "10AM-11AM"] },
    { "name":"p3", "models":[ "10AM-12PM", "1AM- 3AM" ] }

3) Once we receive the response from external system. we are creating records on a custom object for each time slot as a record it will be around 50-100 records.

4) after record creation, we are returning partners list to Client side and showing the users the partner list.

5) after user selecting partner from the list. we are navigating the user to the next screen and we are doing SOQL query and retrieving the time slots and showing to user to select.

6) Once the users selects the slots we are deleting the records from the custom object.

With the current design users are experiencing performance issues. Since records on the custom object are deleted and inserted synchronously.

As we are looking for the alternate approach to cache the data from external system in client. please suggest the best possible approaches.

  • I'm not following the need for data storage other than retaining the data in the component on the client side. What's driving the need for custom caching or database persistence? – David Reed Feb 9 at 1:47
  • @DavidReed - if in case for that service address there is a chance to have more no. of partners than usual for example 200-300 records. to be on safer side we are not directly retaining the data in the component which could lead performance issues right ? So, we want to store the data some where we can access it fast. – Red Rick Feb 9 at 2:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.