Skip to content

Re-enable static route optimization without bug #174

Closed

Description

@coderabbitai

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

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

Activity

  1. added
    area: static assets
    enhancement
    on Sep 18, 2025
  2. moved this from Inbox 📫 to Backlog 🗂️ in Serverpod Frameworkson Sep 18, 2025
  3. nielsenko commented on Nov 26, 2025

    @nielsenko
    Collaborator

    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.

  4. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: static assetsenhancement

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions