14 How does server-side caching work in B2C Commerce and how do developers control it?
Suggested answer
B2C Commerce supports edge caching at the platform level. When a page response is cached, subsequent requests for the same URL are served from the cache without executing server-side scripts, significantly improving performance.
Developers control caching in SFRA controllers by setting properties on the response object:
1. res.cachePeriod = 2; and res.cachePeriodUnit = 'hours'; — caches the full page for 2 hours
2. Setting res.personalized = true; marks a response as personalised and disables shared caching
In ISML templates, the <iscache> tag with type="relative" and hour attributes can also control cache duration at the template level.
Best practice: enable caching on product display pages, category pages, and the homepage. Disable it (or set very short TTLs) on the cart, checkout, account pages, and any page with personalised content. Incorrectly caching a personalised page is a security and correctness risk.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.