Viewing 15 replies - 1 through 15 (of 18 total)
  • I intend to use this plugin to replace WP-Syntax.

    What exactly do you mean by “url is not beeing rewritten”?

    If the file cannot be served by the CDN, that probably means it cannot be fetched from your server, which in turn means that the generated URL is wrong. After checking the source, the dev seems to be using the WP API to enqueue the CSS files, so the generated URL not being correct does not make any sense.

    Could you please provide some more feedback about this?

    Plugin Author Jan-Philip Gehrcke


    Sorry for the late response, acy. I did not retrieve email notification about your inquiry.

    I concur with what George says. I am willing to help out, but could you please provide more information about your issue?

    Plugin Author Jan-Philip Gehrcke


    George, I’d be happy if you used this plugin, and encourage you to provide feedback about any issue you are observing.

    This is how my header looks like:

    The URL to all static files is beeing generated/rewritten correctly by the w3 total cache plugin as I’m using Cloudfront:
    <link rel='stylesheet' id='default-css' href='' media='all' />

    That works fine with all used plugins except yours. It still looks like this:

    <link rel='stylesheet' id='wp_geshi_wp-geshi-highlight-css' href='' media='all' />

    It might be caused by the double slash (“//”)?

    Hi all,

    @Jan-Philip, I think @acy has a point and this is probably a bug.

    This line possibly hardcodes the domain name. IMO, $cssuri should be a relative URI. Please check the notes about the $src parameter.

    Plugin Author Jan-Philip Gehrcke


    Thanks, for your feedback, acy! Indeed, the problem seems to be caused by the double slash you were referring to. I am quite sure, because I think this is a duplicate of your issue:

    While the typical web server (like Apache) auto-collapses subsequent slash occurrences into a single slash, this is really just “too gentle” (and no good, as you will learn in a second), because RFC 2396 specifies that every slash in a URL is significant. So, typical web servers can be considered to violate this specification. If they didn’t, the current plugin code would have never worked, and this bug would not have been part of a released version.

    Even more critics (shame on others :-)): if the WordPress API functions for retrieving URLs or paths were more consistent in having or not having trailing slashs in the returned string, this bug would probably also not have existed. plugin_dir_url() returns a trailing slash, while get_stylesheet_directory_uri() does not. Sigh.. — of course, I should have been more careful with this, the slash behavior at least is clearly documented.

    I am glad that we have this clarified, thanks to your feedback. I will fix this in the next release. Probably even still today, I’ll drop another message in this thread.

    @george: the $src parameter to wp_register/enqueue_style/scripts is expected (recommended, via plugins url() and get_stylesheet_directory_uri()) to be an *absolute* URL, so this is fine. Thanks for looking into it anyway! 🙂

    Plugin Author Jan-Philip Gehrcke


    I have just released version 1.2.4 of the plugin. Could you please try and see if that fixes your issue, acy?

    Oh that was quick 🙂
    Unfortunately the double slash is gone but the URL still not pointing to CDN (Cloudfront):

    <link rel='stylesheet' id='wpgeshi-wp-geshi-highlight-css' href='' media='all' />

    Plugin Author Jan-Philip Gehrcke


    Thanks for the feedback, acy. WP-GeSHi-Highlight dynamically generates URLs with the recommended WP API methods, so currently I do not see an issue there. I think we need to do two things:

    1) You tell me which of your other plugins “work” in your scenario, and I have a look at their source code and try to see how they generate URLs. I expect them to use the same method: plugin_url() and friends.

    2) Please try disabling/re-enabling W3TC once, and go through your W3TC settings. There should be a lot you can configure w.r.t. CDN URL rewriting.

    When searching the web for this topic, there seems to be a whole plethora of scenarios when W3 Total Cache does not rewrite URLs as appropriate:

    What seems to help for some people is to “refresh” their W3TC settings, and/or to manually adjust the settings. It could be that W3TC missed out on the WP-GeSHi-Highlight CSS URL as of the double slash once, and now needs to be forced to re-analyze things. Let’s try this first, if you do not mind!

    @george: the $src parameter to wp_register/enqueue_style/scripts is expected (recommended, via plugins url() and get_stylesheet_directory_uri()) to be an *absolute* URL, so this is fine. Thanks for looking into it anyway! 🙂

    Ooops, sorry, it seems I completely overlooked the notes (where has my mind been?). Thanks for looking into this. 🙂

    OK. I got some feedback. It works as expected in a test web site I tried. I replaced the default domain with the CDN domain using the following code:

    function script_style_cdn_url( $url )
        if( is_admin() ) return $url;
        return str_replace( site_url(), '', $url );
    add_filter( 'script_loader_src', 'script_style_cdn_url' );
    add_filter( 'style_loader_src', 'script_style_cdn_url' );

    And the HTML source had the following expected link:

    <link rel='stylesheet' id='wpgeshi-wp-geshi-highlight-css'  href='' type='text/css' media='all' />

    Jan, please ignore my post about a possible bug and also I’m sorry for any wasted time because of that. Definitely not my brightest moment. 🙂


    UPDATE: Updated the source code.

    [pls ignore this post]

    @acy, it’s been a long time since the last time I used W3TC, but I’d suggest to thoroughly check whether there are any excluded domains/paths set somewhere in the settings.

    Plugin Author Jan-Philip Gehrcke


    Thanks for your valuable input, George. And don’t worry about that $src thing: you were exactly right that I needed to double-check this to make sure that the wp_enqueue_style call is set up properly, and this is what I did, so no time wasted :-).

    Jan, I fixed the code. (had initially pasted wrong snippet)

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘CSS not served by CDN’ is closed to new replies.