Closed
Labels
Description
Background
This follows up on PR #172 (#172) where the static route cache optimization was disabled due to a bug.
The static cache optimization provided performance benefits for static paths (paths without dynamic elements like /:id/, /*/, /**/) by caching lookup results in Router._staticCache.
Request
Re-enable the static route optimization while ensuring the underlying bug that caused its removal is properly fixed.
Context
- Original optimization removed in PR refactor: Rip out Router.staticCache #172: refactor: Rip out Router.staticCache #172
- User request: https://github.com/serverpod/relic/pull/172#issuecomment-[current-comment-id]
- Requested by: @nielsenko
The optimization involved:
- Caching static route lookups in
_staticCache - Priming cache entries when routes were added
- Clearing cache when sub-routers were attached
- Fast lookup path for cached static routes
Acceptance Criteria
- Identify and fix the root cause of the bug that required disabling the optimization
- Re-implement static route caching with proper safeguards
- Add tests to prevent regression of the original bug
- Verify performance benefits are maintained
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone 🚀
Activity
nielsenko commentedon Nov 26, 2025
Due to how middleware is now composed during lookup, this is no longer easy to achieve. The benefit of this optimization is questionable for a framework like Relic anyway, as the number of static routes a negligible. Remember that static files are served with the [StaticHandler] class, which is registered on a dynamic segment.
As Relic allow routes to be added after start, one could imagine an optimization that would dynamically added static routes during runtime, and hence the value of this optimization could increase, but lets wait and see.