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

Cache Clearing - rocket_clean_home_feeds() runs even when feed caching is disabled #4133

Closed
4 tasks
vmanthos opened this issue Jul 6, 2021 · 6 comments · Fixed by #4833
Closed
4 tasks
Assignees
Labels
effort: [XS] < 1 day of estimated development time good first issue Indicates a good issue for first-time contributors module: cache priority: medium Issues which are important, but no one will go out of business. type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Milestone

Comments

@vmanthos
Copy link
Contributor

vmanthos commented Jul 6, 2021

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version ✅ (3.9.0.5)
  • Used the search feature to ensure that the bug hasn’t been reported before ✅

Describe the bug

When rocket_clean_post() runs, rocket_clean_home_feeds() will run as well, even when we are not caching the site's feeds, which is the default:

rocket_clean_home_feeds();

On a Cloudways site, these results in sending 2 PURGE requests to their Varnish. Each of these took 2 seconds.

To Reproduce
Steps to reproduce the behavior:

  1. Install WP Rocket - feeds caching is disabled by default.
  2. Add log statements in rocket_clean_home_feeds().
  3. Clear a post's cache to trigger rocket_clean_post().
  4. Check the log.

Expected behavior

rocket_clean_home_feeds() should run only if someone has activated feed caching.

Additional context
Ticket: https://secure.helpscout.net/conversation/1539262653/270635/
Slack convo: https://wp-media.slack.com/archives/C43T1AYMQ/p1625218864433800

Backlog Grooming (for WP Media dev team use only)

  • Reproduce the problem
  • Identify the root cause
  • Scope a solution
  • Estimate the effort
@vmanthos vmanthos changed the title Cache Clearing - rocket_clean_home_feeds() runs even when cache feeding is disabled Cache Clearing - rocket_clean_home_feeds() runs even when feed caching is disabled Jul 6, 2021
@piotrbak piotrbak added module: cache priority: medium Issues which are important, but no one will go out of business. type: enhancement Improvements that slightly enhance existing functionality and are fast to implement labels Nov 8, 2021
@remyperona
Copy link
Contributor

Since we don't have an option (anymore) for the feed cache, we don't have an easy way to detect if we should or not call the clean function.

I'm wondering though if at that point we should remove the default call of this function in our code, and instead update our helper plugin to hook on after_rocket_clean_post and call the function only when the helper is enabled.

@piotrbak what do you think?

@piotrbak
Copy link
Contributor

Yes, that sounds like the best approach. Thanks @Tabrisrp !

@vmanthos
Copy link
Contributor Author

This approach will result in feeds not being cleared, when we make the change, and will create tickets.

How about using has_filter() for wp_rocket_cache_feed which is used in the helper plugin?
https://github.com/wp-media/wp-rocket-helpers/blob/fe97245d17d5341f206de1638db87bdc0554a141/cache/wp-rocket-cache-feed/wp-rocket-cache-feed/wp-rocket-cache-feed.php#L30

if( false !=== has_filter( 'rocket_cache_reject_uri', 'wp_rocket_cache_feed') ){
   rocket_clean_home_feeds();
}

Here I am making an assumption that whoever has enabled feeds caching has done it using our helper plugin.
If there are customers who've done it differently, they will be affected by the approach I'm suggesting.

I'm guessing they will be less than those that will be affected if we add rocket_clean_home_feeds() in the helper, given that in support and in our docs we suggest using the helper.

@remyperona
Copy link
Contributor

We can do that too, it's true that it will has less side-effect

@juricazuanovic
Copy link
Contributor

@remyperona
Copy link
Contributor

Scope a solution ✅

In rocket_clean_post(), wrap the call to rocket_clean_home_feeds() to check if the helper plugin callback is used.

if ( false !=== has_filter( 'rocket_cache_reject_uri', 'wp_rocket_cache_feed') ) {
   rocket_clean_home_feeds();
}

Estimate the effort ✅

Effort [XS]

@remyperona remyperona added effort: [XS] < 1 day of estimated development time and removed needs: grooming labels Mar 7, 2022
@remyperona remyperona added the good first issue Indicates a good issue for first-time contributors label Mar 14, 2022
@CrochetFeve0251 CrochetFeve0251 self-assigned this Mar 18, 2022
@piotrbak piotrbak added this to the 3.11.1 milestone Mar 28, 2022
CrochetFeve0251 added a commit that referenced this issue May 2, 2022
* Fixes #4757 Exclude AMP redirection script from delay JS (#4827)

* Added amp-mobile-version-switcher to the HTML DelayJs exclusion array

* Added amp-mobile-version-switcher script the delayJs fixture to ensure by automated testing that this script is not deleted

* Reverted changes in DelayJS and fixtures corresponding to it.

* Added a call to the filter rocket_delay_js_exclusions in the AMP Subscriber to exclude amp-mobile-version-switcher

* Wrapped the filter rocket_delay_js_exclusions in the AMP verification to launch it only when it is activated

* Fixed code standards

* Added integration test for the exclude_script_from_delay_js method

* Update version in inc/ThirdParty/Plugins/Optimization/AMP.php

Co-authored-by: Rémy Perona <[email protected]>

* Use configTestData instead of providerTestData tests/Integration/inc/ThirdParty/Plugins/Optimization/AMP/excludeScriptFromDelayJs.php

Co-authored-by: Rémy Perona <[email protected]>

* Remove providerTestData function in tests/Integration/inc/ThirdParty/Plugins/Optimization/AMP/excludeScriptFromDelayJs.php

Co-authored-by: Rémy Perona <[email protected]>

* Removed providerTestData mehod in tests/Unit/inc/ThirdParty/Plugins/Optimization/AMP/excludeScriptFromDelayJs.php

Co-authored-by: Rémy Perona <[email protected]>

* Use configTestData instead of providerTestData in tests/Unit/inc/ThirdParty/Plugins/Optimization/AMP/excludeScriptFromDelayJs.php

Co-authored-by: Rémy Perona <[email protected]>

* Update inc/ThirdParty/Plugins/Optimization/AMP.php

Co-authored-by: Rémy Perona <[email protected]>

* Update tests/Unit/inc/ThirdParty/Plugins/Optimization/AMP/excludeScriptFromDelayJs.php

Co-authored-by: Rémy Perona <[email protected]>

* Update tests/Integration/inc/ThirdParty/Plugins/Optimization/AMP/excludeScriptFromDelayJs.php

Co-authored-by: Rémy Perona <[email protected]>

* Added Integration TestCase

Co-authored-by: Rémy Perona <[email protected]>

* Fixes #4804 Use absint values for width/height values when setting image dimensions of SVG files (#4805)

* Fixes #4527 Remove Rocket option to deactivate lazyload of iframes and YT videos when Autoptimize lazyload is enabled (#4889)

* Closes #4020 Delete metadata from the postmeta table during uninstall (#4855)

* Closes #4133 Clean feeds only if our cache feeds helper plugin is enabled (#4833)

* Fixes #4171 Exclude judge.me script from delay JS (#4839)

* Fixes #4032 Disabling heartbeat causing dependency error in query monitor (#4888)

* Prevent issues when parsing the HTML to apply optimizations (#4838)

* Fixes #4758 Exclude our remove CPCSS script from delay JS (#4824)

* Closes #4896 Update test suite (#4903)

Update our test suite to be cross-compatible with WP and PHPUnit versions

* Prevent PHP 8.1 deprecation notices (#4732)

* Flatsome preserver dynamic #image_ style (PR #4979)

Fixes #4971

* Preserve Health Center dynamic CSS selectors (PR #4976)

* Closes #4867 Update the deactivation form UI (PR #4880)

* Remove render class
* move deactivation form assets to deactivation intent class
* update classes instantiation
* add subscriber class
* update code for new deactivation intent form
* delete new option and transient on uninstall
* remove modal task
* remove old modal CSS
* remove old modal JS
* use micromodal for deactivation modal
* update the form HTML
* update the modal CSS
* update micromodal to v0.4.10
* return type hint
* add transition
* replace divs by list
* remove unneeded comment
* add missing semicolon
* update activate_safe_mode tests
* add unit tests
* add fixtures
* cast option to int
* update used hooks
* remove screen check
* update test and fixture
* integration tests
* fix PHPCS

* Fixes #4868 Apply CDN to used CSS on output instead of on saving (PR #4893)

* Moved the filter and removed the clean_used_css_with_cdn method
* Removed fixtures and integration tests from the method `clean_used_css_with_cdn`
* Added unit tests for treeshake function from UsedCSS controller
* Fixed code standards
* Removed quotes
* Fixed errors with the tests
* replicate magic isset declaration from parent class
* revert previous commit

Co-authored-by: Rémy Perona <[email protected]>

* Fix problem with action scheduler (PR #4965)

* Added fix
* Added fix standards
* Added check on pending
* Fixed search
* Added fix standards
* Fixed to conform to CR
* Fixed code standards
* Fixed code standards
* Changed `search` method usage to keep backward compatibility
* stop bailing out after cancel all actions

Co-authored-by: Ahmed Saeed <[email protected]>

* update plugin version

* Fixed failing test (#4986)

Co-authored-by: COQUARD Cyrille <[email protected]>
Co-authored-by: Rémy Perona <[email protected]>
Co-authored-by: Klemart3D <[email protected]>
Co-authored-by: michael lee <[email protected]>
Co-authored-by: Rémy Perona <[email protected]>
Co-authored-by: Adame Dahmani <[email protected]>
Co-authored-by: Vasilis Manthos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort: [XS] < 1 day of estimated development time good first issue Indicates a good issue for first-time contributors module: cache priority: medium Issues which are important, but no one will go out of business. type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants