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

WP Rocket's cache is cleared after every update #5958

Closed
4 tasks
vmanthos opened this issue Jun 1, 2023 · 2 comments · Fixed by #6079
Closed
4 tasks

WP Rocket's cache is cleared after every update #5958

vmanthos opened this issue Jun 1, 2023 · 2 comments · Fixed by #6079
Assignees
Labels
effort: [XS] < 1 day of estimated development time module: filesystem priority: low Issues that can wait type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Milestone

Comments

@vmanthos
Copy link
Contributor

vmanthos commented Jun 1, 2023

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

  • Made sure you’re on the latest version ✔️ 3.13.3
  • Used the search feature to ensure that the bug hasn’t been reported before ✔️

Describe the bug

When updating WP Rocket the cache is cleared every time although this may not be the intended behavior.
For example, we have code to clear the cache when updating from a version lower than 3.6:

if ( version_compare( $actual_version, '3.6', '<' ) ) {
rocket_clean_cache_busting();
rocket_clean_domain();
}

This is happening because version isn't part of the $removed array:

$removed = [
'cache_mobile' => true,
'purge_cron_interval' => true,
'purge_cron_unit' => true,
'database_revisions' => true,
'database_auto_drafts' => true,
'database_trashed_posts' => true,
'database_spam_comments' => true,
'database_trashed_comments' => true,
'database_all_transients' => true,
'database_optimize_tables' => true,
'schedule_automatic_cleanup' => true,
'automatic_cleanup_frequency' => true,
'do_cloudflare' => true,
'cloudflare_email' => true,
'cloudflare_api_key' => true,
'cloudflare_zone_id' => true,
'cloudflare_devmode' => true,
'cloudflare_auto_settings' => true,
'cloudflare_old_settings' => true,
'heartbeat_admin_behavior' => true,
'heartbeat_editor_behavior' => true,
'varnish_auto_purge' => true,
'analytics_enabled' => true,
'sucury_waf_cache_sync' => true,
'sucury_waf_api_key' => true,
'manual_preload' => true,
'preload_excluded_uri' => true,
'cache_reject_uri' => true,
];

so the following conditional always evaluates to true and rocket_clean_domain() runs clearing the cache:

if ( md5( wp_json_encode( $oldvalue_diff ) ) !== md5( wp_json_encode( $value_diff ) ) ) {

To Reproduce

Steps to reproduce the behavior:

  1. Install WP Rocket 3.13.
  2. After the cache is preloaded disable Preload.
  3. Check the /cache/wp-rocket/ folder.
  4. Update to the latest WP Rocket version (3.13.3 at the time this is written).
  5. Repeat step 3. The cache will have been cleared.

Expected behavior

This issue should be seen as an opportunity to discuss whether we'll keep the current behavior, i.e. clear the cache after every update, or if we want to do that selectively, e.g. with specific versions.

Screenshots

N/A.

Additional context

N/A.

Backlog Grooming (for WP Media dev team use only)

  • Reproduce the problem
  • Identify the root cause
  • Scope a solution
  • Estimate the effort
@piotrbak piotrbak added type: enhancement Improvements that slightly enhance existing functionality and are fast to implement priority: low Issues that can wait module: filesystem labels Jun 1, 2023
@piotrbak
Copy link
Contributor

Acceptance Criteria:

  1. WP Rocket cache should be cleared during the update when this is specified in the wp-rocket/inc/admin/upgrader.php
  2. WP Rocket cache should not be cleared during the update when not asked to

@Tabrisrp
Copy link
Contributor

Reproduce the issue ✅

Reproduced the issue

Identify the root cause ✅

As noted by Vasilis, the version index of the array changes on update, and it's not part of the array of values to ignore, so the clean is triggered on every update

Scope a solution ✅

  • Add version to the $removed array in rocket_after_save_options()
  • Add an additional test fixture to confirm this change

Estimate the effort ✅

Effort XS

@Tabrisrp Tabrisrp added effort: [XS] < 1 day of estimated development time and removed needs: grooming labels Jul 31, 2023
@CrochetFeve0251 CrochetFeve0251 self-assigned this Aug 1, 2023
@piotrbak piotrbak added this to the 3.14.3 milestone Aug 2, 2023
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 module: filesystem priority: low Issues that can wait 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.

4 participants