Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Enable Caching of Apex Results
Annotate the Apex method with @AuraEnabled(cacheable=true), which caches the method results on the client. When you set cacheable=true, a method must only retrieve data, it can’t mutate (change) data.
- Apex methods used in reactive wires must be annotated with @AuraEnabled(cacheable=true), whether you intend to use the results offline or not.
- Apex methods called imperatively only need to be annotated with @AuraEnabled(cacheable=true) if you want the results to be available offline.
Additional details of Apex method caching behavior and managing cached results can be found in the Lightning Web Components Developer Guide.