Exam CRT-450 Topic 3 Question 232 Discussion

Actual exam question for Salesforce's CRT-450 exam
Question #: 232
Topic #: 3
A developer wants to improve runtime performance of Apex calls by caching result on the client.
What is the most efficient way to implement this and follow best practices?

Suggested Answer: C Vote an answer

To improve runtime performance of Apex calls by caching result on the client, the most efficient way to implement this and follow best practices is to decorate the server-side method with @AuraEnabled (cacheable=true). This annotation enables the method to be called from a Lightning web component and also caches the method results on the client. This reduces the number of server requests and improves the responsiveness of the component. The cacheable attribute can only be set to true for methods that are read-only and don't change any data. The other options are not correct because:
* Decorating the server-side method with @AuraEnabled (total=true) does not cache the result on the client, but rather indicates that the method returns the total number of records that match a query.
* Calling the setStorable() method on the action in the JavaScript client-side code is a deprecated way of caching the result on the client for Aura components, not Lightning web components. It also requires more code than using the cacheable attribute.
* Setting a cookie in the browser for use upon return to the page is not a reliable way of caching the result on the client, as cookies can be deleted, expired, or blocked by the browser. It also does not leverage the built-in caching mechanism of the Lightning platform. References:
* Client-Side Caching
* Call Apex Methods from Lightning Web Components
* Free Salesforce Platform Developer 1 Practice Exam (With Answers)

by Murray at Mar 09, 2024, 11:36 AM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10