Make WordPress Core

#38895 closed defect (bug) (fixed)

REST API JS Client should cache schema in sessionStorage by default when available

Reported by: adamsilverstein Owned by: joehoyle
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: has-patch
Focuses: javascript Cc:


The wp-api JS client traverses the schema to build out its models and collections. The schema is generally stable and the client is designed to cached the schema in sessionStorage to avoid repeated requests to retrieve the schema. This behavior can be disabled by developers by setting wpApiSettings.cacheSchema to false; If undefined or true, the schema should be cached.

A bug in the check before storing the schema in sessionStorage means it currently never gets set unless wpApiSettings.cacheSchema is explicitly set to true.

Patch incoming.

Attachments (1)

38895.diff (746 bytes) - added by adamsilverstein 18 months ago.

Download all attachments as: .zip

Change History (4)

#1 @adamsilverstein
18 months ago

@joehoyle I noticed this issue when reviewing the patch on #38342. The schema was getting loaded on each visit to the dashboard. After 38895.diff it only happens once per session.

#2 @joehoyle
18 months ago

  • Milestone changed from Awaiting Review to 4.7

#3 @joehoyle
18 months ago

  • Owner set to joehoyle
  • Resolution set to fixed
  • Status changed from new to closed

In 39344:

REST API: Make JS Client store schema in session storage.

Props adamsilverstein.
Fixes #38895.

Note: See TracTickets for help on using tickets.