Support » Plugin: W3 Total Cache » CDN URL rewrite BROKEN for certain theme css files after latest update

  • After the latest update I just ran tonight, when I view my page as an administrator (when caching should be off) there are several problems:

    – files are still loading from the CDN even though I have the “Don’t replace URLs for following user roles” option checked for all roles.
    – several theme files have a MISSING SLASH in the URL
    – instead of “”
    – the url is “”
    – the cached version of the site appears to load fine.

    Also, if I turn off the CDN, everything loads fine in the admin view… so there’s something off about the way the CDN is implemented.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Frederick Townes


    Could you please submit a bug submission form from the support tab of the plugin? Also there were no changes in the CDN functionality between .7 and .8, so issue is probably elsewhere.

    Thanks Frederick. I did submit a bug report with the exact same issue about a week ago when I originally posted this.

    I found the issue in the lib/W3/plugin/CdnCommon.php file – thanks to this thread:

    lines 544 and 550 of that file trim the URL. If you change the trim function to an ltrim function, that fixes the issue.

    Here’s the full solution (until the next update) thanks to finglandj, as posted here (

    The problem is occurring because of an erroneous replacement.

    There is a script:

    				var srcStrt = "",
    					bioData = [{"filename":"biopic1_1303345244.jpg","url":""},{"filename":"biopic2_1303345256.jpg","url":""},{"filename":"biopic3_1303345281.jpg","url":""},{"filename":"biopic4_1303345304.jpg","url":""}],
    					picNum  = Math.floor(Math.random()*(bioData.length)),
    					markup  = '<img id="biopic" src="'+srcStrt+bioData[picNum].filename+'" width="260" height="390" alt="MN Wedding Photography | Minneapolis Wedding Photographers | Engagement Photographer bio picture" class="bio-col" />';
    				if ( bioData[picNum].url ) {
    					markup = '<a href="'+bioData[picNum].url+'">'+markup+'</a>';

    srcStart is getting modified by uri_to_cdn_uri which trims the trailing slash.

    uri_to_cdn_uri is in w3-total-cache/lib/W3/Plugin/CdnCommon.php
    Lines 544 and 550 trim slashes from the returned url. Changing those to an ltrim ensures the directory structure is maintained.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CDN URL rewrite BROKEN for certain theme css files after latest update’ is closed to new replies.