feat: reuse resources and blocks across page loads#196
Open
shariquerik wants to merge 4 commits into
Open
Conversation
Contributor
Confidence Score: 5/5Safe to merge; all three changes are narrowly scoped and the logic is correct. The cache key includes url, method, and serialized params so cross-page data bleed is not possible. The atomic resource swap and same-page block reuse are straightforward and well-guarded. studio/studio/doctype/studio_page_resource/studio_page_resource.json — cache field lacks a depends_on guard. Reviews (5): Last reviewed commit: "fix: keep the block tree mounted on same..." | Re-trigger Greptile |
shariquerik
force-pushed
the
feat/api-resource-cache-across-page-loads
branch
from
July 16, 2026 11:58
ccd5260 to
0644194
Compare
shariquerik
force-pushed
the
feat/api-resource-cache-across-page-loads
branch
3 times, most recently
from
July 20, 2026 06:37
2b372cf to
83aa17e
Compare
Adds a "Cache data across page loads" option for API Resources, so repeat visits to a page can reuse previously fetched data instead of refetching, keyed on the resource's url, method, and params.
Fixes no-case-declarations lint violation in getResource by wrapping the Document List and API Resource case bodies in blocks.
setPageResources reset resources to {} before awaiting the resource
promises, so components rendered against an empty map for the duration
of the fetch. With caching enabled that turned an instant cache hit into
a flash of empty state. Build the map locally and swap it in once.
The route watcher rebuilt rootBlock from page.blocks on every path change, so navigating between routes served by the same Studio page (e.g. a list and its detail route, or a view switch) reinstantiated the whole tree and destroyed component state. Track the last rendered path: a same-page navigation still refreshes resources and the page script, since route params may have changed, but leaves the existing blocks in place. Path resolution moves into resolvePagePath() and the no-path case returns early.
shariquerik
force-pushed
the
feat/api-resource-cache-across-page-loads
branch
from
July 20, 2026 06:38
83aa17e to
0435b9c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Navigating between Studio pages was always a cold load: every resource refetched and the whole block tree was reinstantiated. Three related changes:
createResourcereturns a cache hit before url/params/transform are applied — a name-only key would serve one page's data to another.setPageResourcesresetresourcesto{}before awaiting the resource promises, leaving components rendered against an empty map for the duration of the fetch. With caching on, that turned an instant cache hit into a flash of empty state. The map is now built locally and swapped in atomically.rootBlockon every path change, so navigating between routes served by the same page (a list and its detail route, a view switch) destroyed component state. It now tracks the last rendered path: same-page navigation still refreshes resources and the page script, since route params may have changed, but leaves the existing blocks in place.Test plan