Apex Caching on the Salesforce CDN

When you cache Apex methods on the Salesforce content delivery network (CDN), you improve performance of your LWR site, and your customers benefit from faster page load times. Only public data from Apex methods is intended to be cached, and it’s only cached for guest users. Apex caching controls differ depending on the type of Apex methods in your site.

Required Editions

Available in: both Salesforce Classic and Lightning Experience
Available in: Enterprise, Performance, and Unlimited Editions. Also available with Marketing Cloud Account Engagement (Pardot) in Professional Edition.
Applies to: LWR, Aura, and Visualforce sites

For Apex methods that you own, enable caching by using caching annotation. Annotate your Apex methods with @AuraEnabled(cacheable=true scope=’global’). And use @wire (LWC) to invoke publicly cacheable Apex actions. To avoid caching private data, annotate only Apex methods that return public data. Learn more about caching annotation in our developer guides.

If your site uses managed packages, caching data from Apex methods in those packages is enabled by default. To disable it, deselect Cache public data from Apex methods in Managed Packages in Workspaces | Administration | Preferences.

The preference Cache public data from Apex methods in managed packages is highlighted in the list of LWR site preferences.
Important
Important Only Apex methods that were annotated for caching in the managed packages get cached. If the Apex methods in the managed packages aren’t annotated, they don’t get cached even when the preference is enabled.

Salesforce controls caching of Apex methods used on standard pages and components, and caches it where appropriate.