Performance & Caching
Minification, compression, multi-layer caching, Razor and request buffering
Performance & Caching
Minification & Compression
- WebOptimizer: CSS/JS minification for all site assets
- WebMarkupMin: HTML minification + Brotli/GZip/Deflate compression (Brotli prioritized)
- Pipeline order: UseWebOptimizer() → UseStaticFiles() → UseWebMarkupMin() (critical for minification to work)
Caching (multi-layer)
- Output Cache: Stores fully-rendered HTML in memory. Page policy = 120s TTL, Sitemap = 30min
- Browser Cache: public, max-age=120, stale-while-revalidate=60
- Static File Cache: /assets/, /css/, /scripts/ → 1 year immutable; /uploads/ → 7 days
- Sitemap Memory Cache: 30 minutes in IMemoryCache
Razor
- Runtime Compilation: Only in Development (saves ~200MB RAM in production)
- Precompiled views: RazorCompileOnBuild=true
Request Buffering
- Global buffering disabled: BufferBody = false
- Selective buffering: Only endpoints that need to re-read the body enable it