Skip to content

Commit a696a8a

Browse files
committed
docs: cache persists for history navigation (back/forward)
Navigation entry keys are stable across history traversal, so cache entries can be reused on back/forward. This provides instant navigation without re-fetching. Cache only clears on full page reload.
1 parent 129128a commit a696a8a

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

docs/DATA_LOADER_ARCHITECTURE.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,30 @@ function getOrCreateLoaderResult(
294294
}
295295
```
296296

297+
### Cache Retention for History Navigation
298+
299+
Navigation entry keys are **stable across history traversal**. When user navigates back/forward, the same entry key is used, enabling cache reuse:
300+
301+
```
302+
Navigate to /users/1 → entry key "abc" → loader runs, cached
303+
Navigate to /users/2 → entry key "def" → loader runs, cached
304+
Press Back → entry key "abc" → cache HIT, no loader execution
305+
Press Forward → entry key "def" → cache HIT, no loader execution
306+
```
307+
308+
This provides instant back/forward navigation without re-fetching data.
309+
297310
### Cache Invalidation
298311

299-
- Clear cache entry when navigating away from a route
300-
- Clear entire cache on full page navigation
312+
Cache entries are **not** cleared on navigation. They persist for the session to support history traversal.
313+
314+
Invalidation occurs:
315+
316+
- On full page reload (cache is in-memory)
301317
- Optionally: provide `revalidate()` function for manual invalidation
302318

319+
**Future consideration**: Cache size limits to prevent unbounded memory growth. Could use LRU eviction for entries not in the current history stack.
320+
303321
## Parallel vs Sequential Loading
304322

305323
### Default: Parallel Loading

0 commit comments

Comments
 (0)