CDN Not Working, Files Not Sent To CDN
If, after activating the CDN option and entering your CNAME in WP Rocket you see that your files are not being served from your CDN, please check the following.
In your WordPress dashboard, go to:
Settings > General
and check how your site URL is written - does it have the www in front of the domain?
Technically speaking, the www and non-www version of your domain name are 2 separate domains. When re-writing the URLs of your files to your CDN, WP Rocket looks for the domain version as specified in your Site Address settings. Any other version is considered external and will not be re-written with the CDN url.
So if you use www in your site settings, you should make sure all links to your files also contain it, otherwise they will not be re-written to your CDN.
Only the the first image will get re-written to the CDN, the other will not because of the lack of www:
Relative Links To Assets
Using relative links to assets is incompatible with the CDN function. You must use absolute links containing a domain name. If there is no domain name, we cannot detect and rewrite them using your CDN name.
For example, this type of format will not work:
This will work:
CDN for logged-in users without cache
The replacement of your domain URL to the CDN URL by WP Rocket is done in two pass.
The first one uses available WordPress filter hooks whenever possible, and will be done for both cached and not cached pages:
The second pass is only applied to cached page, using our rocket_buffer filter hook. It will do the replacement for any CSS/JS file or image that is added on the page and not going through the previous hooks.