Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#38895 closed defect (bug) (fixed)

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

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

Description

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 8 years ago.

Download all attachments as: .zip

Change History (4)

#1 @adamsilverstein
8 years 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
8 years ago

  • Milestone changed from Awaiting Review to 4.7

#3 @joehoyle
8 years 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.