Preload & Caching¶
SkyCMS includes a multi-layer caching system and an admin-only preload function for warming caches. This ensures fast page delivery while keeping content fresh.
Audience: Administrators, Developers
Cache Architecture¶
SkyCMS uses several caching layers, each serving a different purpose:
In-Memory Cache¶
The primary cache is an in-memory cache (ICacheService<T>) that stores frequently accessed data to avoid repeated database queries.
Cached data includes:
| Cache Key | Data | Invalidated By |
|---|---|---|
ArticleRedirects |
All redirect mappings | RedirectCreatedEvent |
ArticleCatalog |
Site navigation catalog | CatalogEntryUpdatedEvent, CatalogEntryDeletedEvent |
SiteMap |
XML sitemap | ArticlePublishedEvent, ArticleUnpublishedEvent |
| Layouts | Page layout templates | LayoutPublishedEvent |
| Copilot options | AI assistant config per tenant | Settings update (30-second TTL) |
Cache Operations¶
The cache service supports:
- Get/TryGet — Retrieve cached values by key.
- Set — Store values with absolute or sliding expiration.
- Remove — Invalidate a specific cache entry.
- Clear — Flush all cached data.
CDN Cache¶
When a CDN is configured (Cloudflare, Azure CDN, CloudFront, or Sucuri), published content is also cached at the edge:
- CDN cache is purged automatically on publish and unpublish.
- Bulk static page generation triggers a full CDN purge.
- CDN configuration is per-tenant.
Cache Invalidation¶
Caches are invalidated automatically through domain events:
| Event | Caches Cleared |
|---|---|
ArticlePublishedEvent |
Redirects, Catalog, SiteMap |
ArticleUnpublishedEvent |
Redirects, Catalog, SiteMap |
LayoutPublishedEvent |
Layouts, Catalog |
CatalogEntryUpdatedEvent |
Catalog, SiteMap |
CatalogEntryDeletedEvent |
Catalog, SiteMap |
RedirectCreatedEvent |
Redirects |
The CacheInvalidationHandler listens for these events and removes the affected cache entries. This ensures the cache stays consistent without manual intervention.
Preload (Cache Warming)¶
Administrators can proactively warm caches to prevent cold-start delays after deployments or cache flushes.
Using Preload¶
- Navigate to Preload in the admin menu (or go to
/Editor/Preload). - The preload view shows:
- PreloadCdn — Whether to also warm the CDN cache (default: enabled).
- PageCount — Number of cache objects that will be created.
- EditorCount — Number of editors involved.
- Trigger the preload operation.
Access: Administrators only.
What Preload Does¶
- Regenerates cached content for all published pages.
- Optionally pre-fetches content through the CDN to warm edge caches.
- Rebuilds the navigation catalog and sitemap caches.
Static File Delivery¶
The Publisher component serves static files from blob storage with intelligent caching:
- Static proxy — The
StaticProxyControllerserves pre-generated HTML files from blob storage. - SPA fallback — For single-page application deployments, the proxy falls back to
index.htmlfor unmatched routes. - Cache keys — The
ICacheKeyProvidergenerates consistent cache keys based on host and path, enabling response-level caching.
Multi-Tenancy¶
- Cache keys include the tenant domain to prevent data leakage between tenants.
- Each tenant has an isolated cache namespace.
- CDN purge operations target only the affected tenant's content.
- Copilot configuration caches use tenant-specific keys with a 30-second TTL.
Performance Tips¶
- Enable static pages for production sites — static HTML served from blob storage is significantly faster than server-rendered content.
- Configure a CDN to cache content at edge locations close to your users.
- Run Preload after deployments to avoid cold-start latency for the first visitors.
- Monitor cache hit rates using structured logging to identify frequently missed cache entries.
See Also¶
- Publishing Modes — Static site generation workflow
- Site Settings — CDN configuration
- Audit & Logging — Cache invalidation events