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
URLs in CSS files aren't rewritten as soon as the CDN is enabled #2425
Comments
Reproduce the issue ✅ Identify the root cause ✅ wp-rocket/inc/admin/options.php Lines 78 to 87 in fbb9380
Mainly this condition is the issue: ( isset( $oldvalue['cdn'] ) && ! isset( $value['cdn'] ) || ! isset( $oldvalue['cdn'] ) && isset( $value['cdn'] )
It seems this condition affects also the JS cache clean, so I assume both should be changed: JS & CSS. Scope a solution ✅ Estimate the effort ✅
The code change itself is very low effort, however it needs both Unit tests & Integration tests for rocket_after_save_options function. @hellofromtonya I would need to check what would happen at CNAME change, should I clean the CSS / JS files? |
About the solution |
So, with JS, then this condition can be removed from line 85 related to wp-rocket/inc/admin/options.php Line 85 in fbb9380
It can be moved in CSS Minify subscriber in a new function which is hooked into: |
the CSS part, not the JS part which is unaffected by the issue at hand. Le'ts move the minified CSS files cleaning to the minify CSS subscriber, and handle the cleaning there, with a new method callback on What do you think? |
This PR #2392 needs to be approved and merged first into develop. PR2392 moves the code in the Engine new architecture and this code should rely in there. |
@crystinutzaa PR #2392 is now approved and in QA. |
… (PR #2532) Co-authored-by: Rémy Perona <remperona@gmail.com> Co-authored-by: hellofromtonya <hellofromtonya@knowthecode.io>
- Enhancement: Add additional exclusions from combine JavaScript (#2472, #2521) - Bugfix: Correctly rewrite assets URLs inside CSS files when updating the CDN or cnames options values (#2425) - Bugfix: Prevent false positives when displaying our cron status notice (#2211) - Bugfix: Prevent some folders from being deleted when clearing the cache on an installation where the domain name is part of the absolute path to the website (#2571, #2574)
When the CDN feature is enabled, we rewrite URLs of static assets that are in the source code of the page and URLs in CSS files, e.g. of background images.
The first time one enables the CDN, the minified/combined files aren't cleared. So, the URLs in there are not rewritten and the images aren't downloaded from the CDN, but from the origin server.
If the cache is cleared, using the admin menu button, the URLs in the newly created files are properly rewritten.
To Reproduce
Steps to reproduce the behavior:
background-image:url(https://eaxmple.com/image.pnp)
in the theme's style.css file.Expected behavior
Rewrite the CSS files URLs, as soon as the option is enabled.
Possible Solution
Clear the minified files when the CDN option is enabled/disabled.
Additional context
An edge case would be if someone disables the CDN and then cancel their subscription.
The CSS files URLs' will still point to the CDN and this will cause
errors 404
.Clearing the cache will fix this, but we can avoid this in the first place.
Related ticket
https://secure.helpscout.net/conversation/1101999708/149719/
Slack Thread
https://wp-media.slack.com/archives/C43T1AYMQ/p1583602741148200?thread_ts=1583602533.148100
Backlog Grooming
The text was updated successfully, but these errors were encountered: