wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Closes #5308 disable cache clearing on activate async features

Open mostafa-hisham opened this issue 2 years ago • 1 comments

Description

disable cache clearing on activate async features RUCSS and Critical path

Fixes #5308

Type of change

  • [x] Enhancement (non-breaking change which improves an existing functionality)

Is the solution different from the one proposed during the grooming?

No

How Has This Been Tested?

  • [x] locally
  • [x] unit and integration

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] New and existing unit tests pass locally with my changes

mostafa-hisham avatar Sep 05 '22 07:09 mostafa-hisham

@piotrbak @mostafa-hisham We missed the fact that treeshake() fires on rocket_buffer: https://github.com/wp-media/wp-rocket/blob/253255a7b2f68472b099eb0a2fa4e7867b555a1a/inc/Engine/Optimization/RUCSS/Frontend/Subscriber.php#L34

This means that if we don't clear the cache upon the first activation of Remove Unused CSS, the used CSS generation will be triggered for:

  • non-cached URLs when they will be visited or preloaded
  • cached URLs whenever their cache is cleared.

If we want to create the used CSS ASAP we should revert the change for Remove Unused CSS and clear it when the feature is activated for the first time..

Regarding Load CSS Asynchronously, we should not clear the cache on the first activation given that CPCSS generation isn't tied to rocket_buffer firing.

vmanthos avatar Sep 12 '22 08:09 vmanthos