Salesforce Decode
Salesforcedecode
Back to questions
LWCAdvancedwirecachingapex

Design wire cacheable Apex with server-side staleness headers

Real World Scenario

cacheable=true Apex returns product pricing stale for 24 hours after admin price update until user clears browser cache.

Expected Answer

• cacheable Apex respects server cache TTL not client control alone • Admin price change publishes LMS pricing_updated invalidating client cache • Version key in wire param: pricingVersion from CMDT bumped on change • Imperative refreshApex after admin save in configuration LWC • Document staleness tolerance in business SLA for pricing display • Non-cacheable imperative for real-time price checkout path • Test cacheable method not called twice same wire param session

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Main difference: use case and scale. cacheable Apex respects server cache TTL not client control alone. Admin price change publishes LMS pricing_updated invalidating client cache. Pick based on your integration pattern and team capability. cacheable wire is performance tradeoff—explicit invalidation strategy required for financial data. Optimize for scale and operational observability.

Architect Perspective

cacheable wire is performance tradeoff—explicit invalidation strategy required for financial data.