Choosing a caching layer for a performance requirement
Key Takeaway
Cache each result at the highest layer that can safely hold it. If a page or remote include must stay dynamic, put its expensive shared work in a custom cache at the application server layer, and fill the cache with Cache.get(key, loader).
Caching in B2C Commerce stores a result so later requests don't have to rebuild it. The platform offers a different cache at each architectural layer. A developer meets a performance requirement by picking the highest layer that can safely hold the data, because every extra layer a request passes through adds response time and lowers how much traffic the site can handle.
The caching layers
A request can be answered at five layers. They form a ladder from the shopper down to the database:
- The shopper's browser
- The CDN
- The web server
- The application server
- The storage layer (database)
An efficient caching strategy moves cached content as high up this ladder as it can, because each layer a request traverses makes responses slower and lowers throughput.
Inside the platform, each server layer has its own caching method.
| Layer | Caching method |
|---|---|
| Web server | Page cache |
| Application server | Custom caches (CacheMgr) |
| Storage layer | Custom attributes or custom objects |