Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Yoast overhead by removing and preventing additional queries for Yoast metadata #563

Open
1 task done
nicholasio opened this issue Jul 18, 2023 · 0 comments · May be fixed by #727
Open
1 task done

Reduce Yoast overhead by removing and preventing additional queries for Yoast metadata #563

nicholasio opened this issue Jul 18, 2023 · 0 comments · May be fixed by #727
Assignees

Comments

@nicholasio
Copy link
Member

nicholasio commented Jul 18, 2023

Is your enhancement related to a problem? Please describe.

We recently did some work to reduce the Yoast payload and optimize hydration but there's still room for improving performance by preventing Yoast from doing a lot of additional queries on WP by disabling these additional queries in the Plugin.

We don't need every post to have an associated yoast_head and yoast_head_json. We only need the first post and the associated queried object to have Yoast metadata.

Bellow are examples of different scenarios and which entities would need the yoast metadata.

Scenarios

Scenario 1

If we're querying for { postType: 'post', slug: 'hello-world' }. Only the first post needs Yoast metadata, There's no queriedObjected on this request so metadata on associated terms can be removed as well.

Scenario 2

If we're querying for { postType: 'post', per_page: 10, category: 'news' }, only the first post and the first term of the news category needs the yoast metadata.

Scenario 3

If we're querying for { postType: 'post', per_page: 10, author: 'jane' }, only the first post and the jane author needs the yoast metadata.

Scenario 4

If we're querying for { postType: 'post', per_page: 10, category: 'news', author: 'jane' }, only the first post. the jane author needs the first term of the news category needs the yoast metadata.

Implementation

We can activate this optimization via headless.config.js.

module.exports = {
	integrations: {
		yoastSEO: {
			enable: true,
                        optimizeYoastPayload: true,
		},
	},
}

Then if optimizeYoastPayload is true our fetch strategies would send a optimizeYoastPayload query param to all requests which would enable the plugin code to optimize yoast metadata. This allows the optimization to be controlled by the front-end versus having to activate via a filter/setting in WP.

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@lucymtc lucymtc linked a pull request Mar 21, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants