Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Load the API much earlier - #1270

#1270
Merged
rachelbaker merged 1 commit into
developWP-API/WP-API:developfrom
early-loadWP-API/WP-API:early-loadCopy head branch name to clipboard
May 21, 2015
Merged

Load the API much earlier#1270
rachelbaker merged 1 commit into
developWP-API/WP-API:developfrom
early-loadWP-API/WP-API:early-loadCopy head branch name to clipboard

Conversation

@rmccue

@rmccue rmccue commented May 21, 2015

Copy link
Copy Markdown
Member

Rather than running the main query, let's run just before it.

Fixes #764.

Rather than running the main query, let's run just before it.
@rachelbaker

Copy link
Copy Markdown
Member

Let's see if this breaks anything.

rachelbaker added a commit that referenced this pull request May 21, 2015
@rachelbaker
rachelbaker merged commit 1f871e4 into develop May 21, 2015
@rachelbaker
rachelbaker deleted the early-load branch May 21, 2015 17:00
@kadamwhite

Copy link
Copy Markdown
Contributor

For my own edification, what's the advantage we'll glean from this change?

@joehoyle

Copy link
Copy Markdown
Member

@kadamwhite faster API requests, and reduced load on your database server.

@rmccue

rmccue commented May 21, 2015

Copy link
Copy Markdown
Member Author

@kadamwhite Without this, the main query will always be run (essentially SELECT * FROM wp_posts LIMIT 10), even though the data isn't actually used. Even with object caching enabled on the site, you'll still hit the database when it could have been cached.

This fixes that, at the expense of moving before some actions/filters might have run, and breaking backwards compatibility.

pdufour added a commit to britco/dynamic-cdn that referenced this pull request Aug 23, 2016
Due to WP-API/WP-API#1270 the "template_redirect" action does not run
when a REST-API request is being served. So hook into rest_api_init so WP-API v2 responses
can be modified.
pdufour added a commit to britco/dynamic-cdn that referenced this pull request Aug 23, 2016
Due to WP-API/WP-API#1270 the "template_redirect" action does not run
when a REST-API request is being served. So hook into rest_api_init so WP-API v2 responses
can be modified.
pdufour added a commit to britco/dynamic-cdn that referenced this pull request Aug 23, 2016
Due to WP-API/WP-API#1270/ the "template_redirect" action does not run
when a REST-API request is being served. So hook into rest_api_init so WP-API v2 responses
can be modified.
pdufour added a commit to britco/dynamic-cdn that referenced this pull request Nov 29, 2016
Due to WP-API/WP-API#1270 the "template_redirect" action does not run
when a REST-API request is being served. So hook into rest_api_init so WP-API v2 responses
can be modified.
pdufour added a commit to britco/dynamic-cdn that referenced this pull request Nov 29, 2016
* Merge

* Add support for WP-API v2

Due to WP-API/WP-API#1270 the "template_redirect" action does not run
when a REST-API request is being served. So hook into rest_api_init so WP-API v2 responses
can be modified.

* Add json test case

* Remove equal sign in regex

- This allows the search and replace to match things like {"blah": "image url"}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Run on an earlier action (work without WP_USE_THEMES and avoid main query)

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.