Skip to content
This repository has been archived by the owner. It is now read-only.

Load the API much earlier #1270

Merged
merged 1 commit into from May 21, 2015

Conversation

@rmccue
Copy link
Member

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.
@rmccue rmccue added this to the 2.0 Beta 2 milestone May 21, 2015
@rachelbaker

This comment has been minimized.

Copy link
Member

commented May 21, 2015

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
3 checks passed
3 checks passed
Scrutinizer No new issues
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on develop at 86.94%
Details
@rachelbaker rachelbaker deleted the early-load branch May 21, 2015
@kadamwhite

This comment has been minimized.

Copy link
Contributor

commented May 21, 2015

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

@joehoyle

This comment has been minimized.

Copy link
Contributor

commented May 21, 2015

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

@rmccue

This comment has been minimized.

Copy link
Member Author

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 pdufour referenced this pull request Aug 23, 2016
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
4 participants
You can’t perform that action at this time.