[Plugin: W3 Total Cache] Unexpected CSS @import UriRewriter behaviour
-
I’ve been trying out W3 Total Cache with the intention of using it for CSS/JS minification and caching on a number of sites I maintain – however, I’ve noticed some unexpected behaviour with respect to the rewriting of CSS
@import
URI’s when debug is enabled and disabled. Basically, I’m finding that the URI rewriting ISN’T working when minification debug is DISABLED, and DOES work when minification debug is ENABLED.For the sake of this example, lets assume I’ve got a stylesheet (
style.css
) stored in the top level directory of my theme named ‘mytheme’ – and that this stylesheet file contains a single CSS@import
statement containing a relative link to a PHP file (Conditional CSS) which generates the actual CSS output (which is stored in a subdirectory named ‘styles
‘).So, I update the W3 Total Cache configuration to add the (relative) path to the theme stylesheet:
wp-content/themes/mytheme/style.css
The style.css file contains a single
@import
as follows:@import url("styles/c-css.php");
The W3TC-generated CSS file is added to the HTML markup and is located at:
wp-content/w3tc/min/default.include.css
When I view the contents of this file via my browser, the
@import
URI is unmodified – since the URI is relative it no longer resolves since the location of the W3TC-generated CSS file is different to the original CSS file.When I turned on the minification debug to figure out what was going on, and then viewed the contents of the W3TC-generated CSS file, the
@import
URI had been correctly rewritten to specify the full path from the document root of my installation, i.e./* Minify_CSS_UriRewriter::$debugText docRoot : /path/to/docroot currentDir : /path/to/docroot/wp-content/mytheme file-relative URI : styles/c-css.php path prepended : /path/to/docroot/wp-content/themes/mytheme/styles/c-css.php docroot stripped : /wp-content/themes/mytheme/styles/c-css.php traversals removed : /wp-content/themes/mytheme/styles/c-css.php */ /* style.css */ /* 1 */ @import url("/wp-content/themes/mytheme/styles/c-css.php");
I’ve tried turning on and off minification debug and the results are repeatable and consistent. I’m not sure if its a result of some interaction or conflict with other plugins that I may have installed – I may retest with all other plugins disabled to see if the end result is the same.
I’m using W3TC version 0.8.5.2
- The topic ‘[Plugin: W3 Total Cache] Unexpected CSS @import UriRewriter behaviour’ is closed to new replies.