nerdexam
Salesforce

PDI · Question #90

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?

The correct answer is C. Decorate the server-side method with @AuraEnabled (cacheable-true. To improve runtime performance of Apex calls by caching results on the client, the most efficient and best practice approach is to decorate the server-side Apex method with @AuraEnabled(cacheable=true).

Submitted by eva_at· Apr 18, 2026User Interface

Question

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?

Options

  • ADecorate the server-side method with @AuraEnabled (total-true).
  • BCall the setStoeable () method on the action in the javaScript client-sidecode.
  • CDecorate the server-side method with @AuraEnabled (cacheable-true.
  • DSet a ciikie in the browser for use upon return to the page.

How the community answered

(40 responses)
  • A
    3% (1)
  • B
    8% (3)
  • C
    90% (36)

Why each option

To improve runtime performance of Apex calls by caching results on the client, the most efficient and best practice approach is to decorate the server-side Apex method with `@AuraEnabled(cacheable=true)`.

ADecorate the server-side method with @AuraEnabled (total-true).

The `total-true` attribute for `@AuraEnabled` is not a valid or recognized parameter for enabling client-side caching in Apex methods; the correct parameter is `cacheable=true`.

BCall the setStoeable () method on the action in the javaScript client-sidecode.

While `setStorable()` was used in Aura Components to mark actions as cacheable, for Lightning Web Components, the `(cacheable=true)` annotation on the Apex method is the declarative and preferred approach to enable client-side caching.

CDecorate the server-side method with @AuraEnabled (cacheable-true.Correct

Decorating an `@AuraEnabled` server-side Apex method with `(cacheable=true)` enables the Lightning Component framework to cache the method's results on the client-side. This significantly improves performance for read-only data by avoiding unnecessary server round trips, adhering to best practices for data retrieval in Lightning Web Components.

DSet a ciikie in the browser for use upon return to the page.

Setting a cookie in the browser to cache data is a manual, less secure, and less performant approach compared to the built-in Lightning framework caching mechanisms, and does not integrate with Lightning Data Service or security features.

Concept tested: Client-side caching of Apex call results

Source: https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.apex_wire_method_cacheable

Topics

#Apex#Caching#Performance Optimization#Lightning Web Components

Community Discussion

No community discussion yet for this question.

Full PDI Practice