[wp-trac] [WordPress Trac] #47871: Cache item schema in REST controllers
WordPress Trac
noreply at wordpress.org
Tue Aug 13 19:17:07 UTC 2019
#47871: Cache item schema in REST controllers
-------------------------+--------------------
Reporter: joehoyle | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: 5.3
Component: REST API | Version: 4.7
Severity: normal | Keywords:
Focuses: |
-------------------------+--------------------
The `get_item_schema` method on the REST controllers should be idempotent.
These methods are called many times when validating schemas, sanitizing,
`filter_response_by_context`, etc, and generating them isn't particularly
cheap.
https://core.trac.wordpress.org/ticket/41305 demonstrates one such place
that adds overhead, also the Posts controller `get_item_schema` makes many
calls and asks for a lot of data:
https://github.com/WordPress/WordPress/blob/master/wp-includes/rest-
api/endpoints/class-wp-rest-posts-controller.php#L1872
We should look into caching these on the class instance. Doing a count on
how many times these methods are called, say on a `/wp-json/` request
should be easy, and indicate if there will be significant performance
gains by doing this.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47871>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list