Skip to content

Note 1 per-parameter keep-alive

/notes/{id:int} with KeepAlive KeepAliveMax="2": every note id you visit keeps its own live instance, LRU-evicted over the budget of 2.

This note's state (instance #2)

Clicks this note's instance has seen: 0

Type a draft, switch to another note, come back: the draft resumes exactly where you left it - unlike the singleton /sticky keep-alive, notes 1 and 2 do not share an instance. The "instance #" stamp reveals recreation: it changes only when this note's instance was evicted and rebuilt.

Switch notes (budget: 2)

Edit notes 1 and 2, then visit note 3: the budget is 2, so the least-recently-used note is evicted - return to it and its draft is gone (fresh instance #), while the other survivor still resumes. The cache key is the route's template parameter values; query-string variations share one instance.

Evict on demand

Disposes every retained (hidden) keep-alive page across the app - the other notes here and the /sticky page - keeping only this visible one. Use it on sign-out or to reclaim memory. Routes that don't declare their own budget fall back to BrouterOptions.DefaultKeepAliveMax (default 1: the singleton, re-binding behavior).

Rebuild the visible page

The one thing plain ClearKeepAlive() deliberately won't do: both of these bring the note on screen back with a new instance stamp, an empty draft and zero clicks. includeActive: true only throws the instances away (no navigation, no guards or loaders); ReloadAsync() additionally re-runs the whole pipeline, so route loaders fetch again. Either way the URL never moves - and clicking this same link instead changes nothing: Blazor keeps a component whose route and parameters didn't change, so a same-URL navigation can never rebuild it. Use them after switching tenant/user or anything else that invalidates what the page read once in OnInitialized.