- Concepts
Loaders cache layer and tags revalidation
Loaders have a caching layer that stores their execution results, including page and dictionary data. The Angular Content SDK uses the unstorage module for underlying cache semantics. It operates on the stale-while-revalidate principle to minimize requests to the SitecoreAI Edge endpoint and optimize front-end performance.
Cache initialization
Caching is initialized in the src/server.ts file and passed into the Angular SSR layer:
By default, caching is enabled and uses the unstorage memory driver, which stores data in runtime system memory.
The memory driver is not optimal for production deployments in serverless environments such as Vercel or Netlify. For these scenarios, import and use a custom unstorage driver. For the full list of supported drivers, refer to the unstorage drivers documentation.
Cache configuration
You can configure caching and revalidation at three levels:
- Global
- Per-loader
- Per-route
Global configuration
Global cache settings are available in sitecore.config.ts under the angular.loadersCache section:
Per-loader configuration
You can pass cache options to individual loaderResolver calls in app.routes.ts. The following example disables caching for all page loader executions across all routes:
Per-route configuration
You can also configure loaders differently for specific routes:
Per-route cache options reference
The PerRouteLoaderCacheConfig interface describes all available per-route caching options:
Property | Type | Description |
|---|---|---|
| number | Time-to-live (TTL) in seconds. A positive value N, expires the entry after N seconds. Setting to 0 or a negative value means the entry never expires. |
| boolean | When |
| string[] | Custom tags applied to every entry the loader writes. This is merged with built-in tags ( |
Cache tags and revalidation
Every cache entry is automatically tagged with contextual metadata:
- For dictionary and page loader data -
locale - For page loader data only - item ID, variant ID, route, and other request data
You can also apply custom tags via the tags option in your cache configuration.
The revalidate endpoint
The Content SDK exposes a /api/revalidate endpoint that enables conditional revalidation of cache entries by tag. This allows partial cache invalidation to be triggered via webhooks (for example, from Sitecore Edge).
Configure the revalidation middleware in src/server.ts. It must receive the same cache instance passed to the Angular SSR layer: