Editor: Preload bound single-resource GETs the post editor would otherwise fetch post-mount#11948
Editor: Preload bound single-resource GETs the post editor would otherwise fetch post-mount#11948ellatrix wants to merge 1 commit into
Conversation
…rwise fetch post-mount.
Adds four entries to `\$preload_paths` in `wp-admin/edit-form-blocks.php`:
* `/wp/v2/templates/lookup?slug=front-page` — used by the editor's
homepage actions gate (`shouldShowHomepageActions`).
* `/wp/v2/taxonomies?context=edit` — read by the post-taxonomies
sidebar panel; non-paginated endpoint with a small bounded payload.
* `OPTIONS` for the current post-type collection — collection-level
permission probe.
* `/wp/v2/users/{author}?context=view&_fields=id,name` — read by the
post-author panel.
Each of these is captured today as a post-mount network fetch by
Gutenberg's post-editor preload e2e spec; preloading them eliminates
those requests from the boot path.
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
What?
Adds four entries to
\$preload_pathsinwp-admin/edit-form-blocks.php:/wp/v2/templates/lookup?slug=front-page/wp/v2/taxonomies?context=editOPTIONSfor the current post-type collection (viarest_get_route_for_post_type_items( \$post_type ))/wp/v2/users/{author}?context=view&_fields=id,nameWhy?
Each of these is captured today as a post-mount network fetch by Gutenberg's post-editor preload e2e spec — the editor fires them on first mount but they aren't currently preloaded server-side. Adding them to
\$preload_pathslets the kickoff consume the data from the inline cache and removes the network round-trip from the boot path.The corresponding callers:
templates/lookup?slug=front-page—shouldShowHomepageActionsinpost-actions/actions.jscallsgetDefaultTemplateId({ slug: 'front-page' })while computing actions for the current post. (It also gatesgetHomePagefor sites withshow_on_front !== 'page'.)taxonomies?context=edit—PostTaxonomiesCheck/PostTaxonomiesread the registered taxonomy list. The endpoint is non-paginated (response is an object keyed by slug), small bounded payload.OPTIONS /wp/v2/posts(or whichever post-type) — collection-levelcanUserprobe for the current post type.users/{author}?context=view&_fields=id,name— the post-author panel reads the author display name.per_page=-1queries (comments, wp_pattern_category) are intentionally not preloaded — those payloads are unbounded.Gutenberg counterpart
WordPress/gutenberg#78565
Trac ticket
(to be filed)
Testing
After this change, the Gutenberg post-editor preload spec (
test/e2e/specs/preload/post-editor.spec.js) asserts that none of these four URLs fire as post-mount network requests anymore — they cache-hit from the preload payload.