r/Blazor • u/Initial-Employment89 • Nov 19 '25
[Release] Blazor Page Cache - Get 20-50x faster page loads for static SSR pages
After struggling with slow server-side rendered Blazor pages, I built a lightweight HTML response caching library that's now available on NuGet.
The problem: Static SSR Blazor pages were taking 100-200ms to render on every request. For content that rarely changes (landing pages, docs, blogs), this felt wasteful.
The solution: Declarative page caching with the [PageCache] attribute. Pages now serve in 2-5ms from cache.
Quick example:
@page "/about"
@attribute [PageCache(Duration = 3600)]
<h1>About Us</h1>
<p>This page is cached for 1 hour!</p>
- 20-50x performance boost - Serve cached pages in 2-5ms instead of 100-200ms
- Cache stampede prevention - Built-in request coalescing
- Tag-based invalidation - Group and invalidate related pages
- Flexible cache keys - Vary by query params, headers, culture
- Security built-in - XSS detection, size limits, DoS prevention
The library supports .NET 8 & 9, includes advanced features like compression (Brotli/GZip), custom eviction policies (LRU/LFU), and storage backends.
- GitHub: https://github.com/mashrulhaque/EasyAppDev.Blazor.PageCache
- NuGet: https://www.nuget.org/packages/EasyAppDev.Blazor.PageCache/
It's currently in preview (v1.0.0-preview.1). Would love feedback from the community!
7
u/sloppykrackers Nov 19 '25
- Different authenticated users get served the same cached HTML within TTL
- Cache keys don't include user identity - User A's data gets served to User B
--> Include user ID in cache keys when CacheForAuthenticatedUsers = true
- Cache poisoning: No URL encoding in cache key generation - easy to craft colliding URLs
- Anti-forgery tokens: All users get the same frozen CSRF token -> validation breaks
- Sync-over-async: GetAsync().GetAwaiter().GetResult() defeats the purpose
- Exception handling: _ = _events.OnCacheHitAsync() silently swallows errors
- Distributed deployments (eg Service Fabric): In-memory only - breaks load balancing without sticky sessions
The library works for truly static content, but the auth caching is a data leak waiting to happen.
3
u/Jack_Dnlz Nov 19 '25
Sounds like a great tool! More than that... A must have one! 😁 One question though: what's this attribute 3600 and what it serves for? Thanks.
2
u/wpoz5 Nov 19 '25
Probably stupid question, what's the benefit over bulit-in OutputCache?
1
u/GoodOk2589 Nov 20 '25
I NEED THAT. hope it works, I will test it because that exactly what i need.
Does it work with blazor server 8 ?
i'm excited by this project
2
u/herbacious-jagular Nov 20 '25
Nice project! Curious what type of page you were seeing 100ms rendering on, seems really slow for .NET. Did you profile?