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

Don't cache not valid taxonomy frontend pages and stop applying optimizations #6984

Merged

Conversation

wordpressfan
Copy link
Contributor

@wordpressfan wordpressfan commented Sep 19, 2024

Description

Fixes https://github.com/wp-media/wp-rocket.me/issues/4164

In this pull request, we are checking if the current frontend page is a taxonomy page and it has a not valid url schema, then we disable this page's caching, also stop applying all optimizations there.

Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • Breaking change (fix or feature that would cause existing functionality to not work as before).

Detailed scenario

As mentioned in the issue itself:

if i visit wordpress.org at:
https://wordpress.org/news/category/releases/ i get a response 200 and see the content.

Then again if i change the url so the last part still exists, something like:
https://wordpress.org/news/category/i_just_added_something_here/releases/

Technical description

Documentation

Here we get all public taxonomies that have UI pages and compare the current page's query var with the taxonomies query vars.
We provided also a filter rocket_cache_taxonomy_query_vars so we can include or exclude taxonomy query vars from that functionality.

New dependencies

No

Risks

The only thing that I can think of, is that we will prevent those pages from being cached as they were already cached but that's to fix the mentioned issue.

Also for @wp-media/qa-team,
In this PR, we also added a change to check if the rocket_buffer filter returns empty HTML, then we will revert back to the main page's HTML, so if you used the following snippet as an example:

add_filter( 'rocket_buffer', function ( $html ) {
    return '';
} );

Before this PR, the page will be blank, but with this PR, we will show the not optimized page.

Mandatory Checklist

Code validation

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

Additional Checks

  • In the case of complex code, I wrote comments to explain it.
  • When possible, I prepared ways to observe the implemented system (logs, data, etc.).
  • I added error handling logic when using functions that could throw errors (HTTP/API request, filesystem, etc.)

Copy link

codacy-production bot commented Sep 19, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 8b46e6b1 51.85% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (8b46e6b) Report Missing Report Missing Report Missing
Head commit (d01ebd7) 37781 16617 43.98%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6984) 27 14 51.85%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@remyperona
Copy link
Contributor

@wordpressfan I think the changes look good to fix the issue at hand, are you waiting for something before moving it forward to review?

@wordpressfan
Copy link
Contributor Author

This PR was a POC to validate the idea, so it needs to be adapted to be a real PR, like fixing phpcs and tests.

@wordpressfan
Copy link
Contributor Author

I'm working on tests now

@wordpressfan wordpressfan changed the title POC of not caching not valid taxonomy frontend pages and stop applying optimizations Don't cache not valid taxonomy frontend pages and stop applying optimizations Oct 16, 2024
@wordpressfan wordpressfan marked this pull request as ready for review October 16, 2024 13:13
Copy link
Contributor

@hanna-meda hanna-meda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @wordpressfan. Everything looks good, exploratory and otherwise.
Related Tests Results Report below:
testrail-report-650.pdf

@wordpressfan wordpressfan added this pull request to the merge queue Oct 29, 2024
Merged via the queue into develop with commit e3f4dcb Oct 29, 2024
13 checks passed
@wordpressfan wordpressfan deleted the fix/donnot-cache-and-optimize-not-valid-taxonomy-pages branch October 29, 2024 07:40
@wordpressfan wordpressfan mentioned this pull request Nov 5, 2024
11 tasks
@piotrbak piotrbak added this to the 3.17.2 milestone Nov 5, 2024
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 this pull request may close these issues.

4 participants