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

Add a filter to disable Homepage cache clearing in function rocket_clean_post #7276

Closed
wants to merge 1 commit into from

Conversation

emiel9d
Copy link

@emiel9d emiel9d commented Feb 5, 2025

Description

Fixes #7187
Adds a filter which gives developers the opportunity to disable the purging of the homepage cache whenever the function rocket_clean_post is triggered.

Type of change

  • Enhancement (non-breaking change which improves an existing functionality).

Detailed scenario

I some cases the automatic purging of the homepage cache whenever the function rocket_clean_post is called is not desirable. For example if you run a WooCommerce webshop with stock management. Whenever an order is placed the function rocket_clean_post will get called. If you have a busy webshop, for example every 5 minutes an order, the homepage cache would be cleared every 5 minutes. Pre-loading the cache won't help if the webshop has a lot of products, it would take too long before the homepage would get pre-loaded.

Technical description

Documentation

The filter itself does nothing, developers can hook into it and return false to prevent the homepage cache from being cleared.

New dependencies

None.

Risks

None.

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.

Unticked items justification

I'm uncertain in which style WP Rocket likes to have the comments. The change is simple enough to add.

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.)

@MathieuLamiot
Copy link
Contributor

MathieuLamiot commented Feb 9, 2025

The filter must use wpm_apply_filters_typed & will need at least one test to capture the filter's behavior.

@Miraeld
Copy link
Contributor

Miraeld commented Feb 10, 2025

As this PR is on the user own repo, I'm closing it in favor of #7297

@Miraeld Miraeld closed this Feb 10, 2025
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.

Add a filter to disable Homepage cache clearing
3 participants