WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
[resolved] Rewritten CSS URL doesn't match uploaded CSS URL (9 posts)

  1. Mikzi
    Member
    Posted 4 years ago #

    When upgrading to the latest version of WP (3.0.1) the rewritten CSS URL no longer matches the uploaded CSS URL. This issue appeared on three separate WordPress installations that I'm running after the upgrade.

    The sites are using the latest plugin version 0.9.1.3 of W3 Total Cache. The settings are the default ones with CDN (Cloudfront) configured. "Rewrite URL structure" is enabled under Minify settings since disabling this setting seems to prevent uploading of minified files to my CDN in this version of the plugin ("Host minified CSS and JS files" becomes grayed out).

    Basically, the CSS URL "http://www.mysite.com/wp-content/themes/mytheme/style.css"
    Is rewritten as "http://mycloud.cloudfront.net/wp-content/w3tc/min/f1b32b/default.include.2648424108.css.gzip".

    However, the Minified CSS file is uploaded to the following Amazon CloudFront directory:
    mydir/wp-content/w3tc/min/f1b32b/default.include.2648424108.css.gzip OK
    mydir/wp-content/w3tc/min/f1b32b/default.include.2648424108.css OK

    The "mydir" part is the problem (or lack of "mydir" in the rewrite). This is the name of the physical directory WP is installed at (different for each site).

    I'd be very grateful if someone could shed some light into this mystery.

  2. Frederick Townes
    Member
    Plugin Author

    Posted 4 years ago #

    Is your site in network mode?

  3. Mikzi
    Member
    Posted 4 years ago #

    No. Each site has a separate WP install and database, although they're located on the same web host.

    In the Minify settings the CSS file is specified as "wp-content/themes/mytheme/style.css". The URI verifies correctly. Interestingly, specifying the URI as "mydir/wp-content/themes/mytheme/style.css" produces the exact same result. The URI verifies, the uploaded file gets prefixed with "mydir" while the rewritten CSS URL does not.

  4. Mikzi
    Member
    Posted 4 years ago #

    It seems the issue is not specific to minified CSS files. Theme files and WP-includes are also uploaded to the subdirectory mydir on Cloudfront, while their URL is rewritten without the mydir on the web pages.

  5. Mikzi
    Member
    Posted 4 years ago #

    To confirm, this problem appeared when switching from 0.9.1.2 to 0.9.1.3. I did some analyses of the code and believe the source of this issue to be the w3_get_document_root() function in define.php which has received some additional calls from /lib/W3/Plugin/Cdn.php in the new version.

    For example, in the previous version of Cdn.php we had that the minify path was a constant "W3TC_CONTENT_MINIFY_DIR_NAME" defined as "wp-content/w3tc/min". In the new version (line 1385) this path becomes the W3TC_CACHE_FILE_MINIFY_DIR subtracted from w3_get_document_root().

    In my case the doc root /myhome/public_html is removed from the constant /myhome/public_html/mydir/wp-content/w3tc/min, leaving the path as mydir/wp-content/w3tc/min instead of the desired /wp-content/w3tc/min.

    I believe w3_get_document_root() should have returned "/myhome/public_html/mydir" and not "/myhome/public_html".

  6. Frederick Townes
    Member
    Plugin Author

    Posted 4 years ago #

    Can you submit a bug submission form from the support tab of the plugin?

  7. Mikzi
    Member
    Posted 4 years ago #

    Done.

  8. Frederick Townes
    Member
    Plugin Author

    Posted 4 years ago #

    Thanks.

  9. Mikzi
    Member
    Posted 4 years ago #

    Thanks for the help, Frederick.

    The problem has been solved so I'm closing this thread. It had to do with my custom .htaccess rules and the fact that my WP SiteUrl was incorrect.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic