Storable Actions are a GREAT way to enhance the performance of your Lightning components and implementing them is incredibly easy, but there is one big gotcha to seeing them work with a stand-alone Lightning Application.
Even though storable actions are automatically configured in Lightning Experience and Salesforce1, any Stand-alone Lightning apps that are used to host your components will NOT use caching by default.
For these apps to use storable actions, you must do these two things:
1.) Add a new component which you can name whatever you want, but I named mine AppTemplateComponent and have it use the following code:
2.) You then need to add the following attribute to the aura:application tag of your Lightning Standalone app:
Once you do this, you should be able to see the caching working for any component used in that app that calls the following line of code:
Isn’t that amazing?
Just one line of code is all you need to add to start taking advantage of caching in your server-side actions. The impact on performance can be amazing and perhaps the best place to see is when it comes to rendering a list of data (especially if that data is non-mutable and therefore will not be updated).
This best practice really is a no brainer that everyone building Lightning Components should consider using.
If you found this article useful, you might want to checkout my latest course on Pluralsight titled, Lightning Component Development Best Practices, where I talk about storable actions and a lot more.
One thought on “Lightning Best Practice: Storable Actions”
This is really Awesome, Thanks!