Salesforce Certified Platform Developer II — Question 23
A developer wishes to improve runtime performance of Apex calls by caching results on the client.
What is the best way to implement this?
Answer options
- A. Decorate the server-side method with @AuraEnabled(cacheable=true).
- B. Set a cookie in the browser for use upon return to the page.
- C. Call the setStorable() method on the action in the JavaScript client-side code.
- D. Decorate the server-side method with @AuraEnabled(storable=true).
Correct answer: A
Explanation
The correct answer is A because using @AuraEnabled(cacheable=true) allows the results of the Apex call to be cached on the client, improving performance. Option B is incorrect as setting a cookie does not provide the same caching benefits for Apex calls. Option C is also incorrect because setStorable() is not used in the context of caching Apex results, and option D is wrong as there is no @AuraEnabled(storable=true) annotation; the correct annotation is cacheable.