Feb, 2016
Why are the Static CDN Filters not rewriting all of my static resource URLs?
When the Comet Cache Static CDN Filters are enabled, Comet Cache will attempt to rewrite all static resource URLs on your site so that those resources point to the configured CDN. If some of your static resource URLs are not changing and you've verified that those file extensions and URIs have not been excluded via the Blacklisted File Extensions or Blacklisted URI Exclusion Patterns (see WordPress Dashboard → Comet Cache → Plugin Options → Static CDN Filters), then your WordPress theme, and/or one or more of your WordPress plugins, may not be implementing proper WordPress coding standards, thereby preventing Comet Cache from properly rewriting those URLs.
The WordPress Plugin API provides many hooks that allow other WordPress plugins, such as Comet Cache, to "filter" the values of things (such as URLs) so that they can be changed in a dynamic way. However, if a WordPress theme or plugin does not implement the Plugin API, then other plugins (such as Comet Cache) won't be able to change any of that content (e.g., a URL).
A Common Mistake: WP_CONTENT_URL
An example of a common mistake that we've seen other WordPress plugin and theme developers make is referencing WP_CONTENT_URL
directly in their theme or plugin, instead of properly calling content_url()
(see WordPress Codex).
If a developer uses WP_CONTENT_URL
instead of content_url()
, then Comet Cache has no way of rewriting the URLs to static resources referenced by the theme or plugin. As a result, when you enable Static CDN Filters and view your site source code, you may see that only some of the static resources are pointing at your CDN.
Important Functions for WordPress Plugin/Theme Developers
Here are the most common functions used when constructing links to static resources in a WordPress plugin or theme:
site_url()
(see Function_Reference/site_url)content_url()
(see WordPress Function_Reference/content_url)plugins_url()
(see WordPress Function_Reference/plugins_url)wp_enqueue_script()
(see WordPress Function_Reference/wp_enqueue_scriptwp_enqueue_style()
(see WordPress Function_Reference/wp_enqueue_style)
If a theme or plugin developer follows best-practice and uses these functions when building links to static resources, the Comet Cache Static CDN Filters won't have any problem rewriting the URLs to use the CDN.
How can I fix my theme or plugin?
If you are experiencing an issue with your theme or one of the plugins you're running on your site, where the Comet Cache Static CDN Filters are not rewriting all of the static resource URLs generated by your theme and/or other WordPress plugins, we suggest contacting the theme/plugin developer to request that they update their plugin/theme to use proper WordPress coding standards, as described above. You can reference this KB Article when contacting them.