Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Load the API much earlier #1270

Merged
merged 1 commit into from
May 21, 2015
Merged

Load the API much earlier #1270

merged 1 commit into from
May 21, 2015

Conversation

rmccue
Copy link
Member

@rmccue rmccue commented May 21, 2015

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
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
Contributor

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

@joehoyle
Copy link
Member

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

@rmccue
Copy link
Member Author

rmccue commented May 21, 2015

@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