• Resolved Ravindran

    (@ravindran214)


    Valid URI for CDN accepted by Autoptimize mandates protocol as well. CDN URL replacement is working fine for both JS & CSS. However, am facing problem with below case.

    We can specify static resources without protocol. (E.g., “//abc.com/static/a.png”) This is to make sure that everything works fine for the site with both http & https. Resource is fetched with same protocol as the top page and there will not be any mixed content alert.

    Due to this, some of the resource are fetched from site instead of CDN or fetched twice (once from CDN & another from site). ??

    Let me know if you need more info.

    https://www.ads-software.com/plugins/autoptimize/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Frank Goossens

    (@futtta)

    hmmm … if the resource is fetched from the same domain as your top domain or if the domain is the same as your cdn-domain, this actually should work ravindran214, AO takes protocol-less URL’s into account, but there might be some edge case that is not covered (obviously).

    could you share a URL where I can see this happening?

    frank

    Thread Starter Ravindran

    (@ravindran214)

    Thanks for the quick reply.

    Sure. Below are the site related info. Please let us know if I do anything wrong.

    site: https://www.joyofcookingandbaking.com
    CDN Base URL in Autoptimize: https://cdn.joyofcookingandbaking.com

    You can look at the CSS file which has few webfonts. Webfont SRC path points to the parent site without protocol. These are not modified to CDN URLs.

    @font-face {
        font-family: 'FontAwesome';
        src: url(//www.joyofcookingandbaking.com/wp-content/themes/oblique/fonts/../fonts/fontawesome-webfont.eot?v=4.3.0);
        src: url(//www.joyofcookingandbaking.com/wp-content/themes/oblique/fonts/../fonts/fontawesome-webfont.eot?#iefix&v=4.3.0) format('embedded-opentype'),url(//www.joyofcookingandbaking.com/wp-content/themes/oblique/fonts/../fonts/fontawesome-webfont.woff2?v=4.3.0) format('woff2'),url(//www.joyofcookingandbaking.com/wp-content/themes/oblique/fonts/../fonts/fontawesome-webfont.woff?v=4.3.0) format('woff'),url(//www.joyofcookingandbaking.com/wp-content/themes/oblique/fonts/../fonts/fontawesome-webfont.ttf?v=4.3.0) format('truetype'),url(//www.joyofcookingandbaking.com/wp-content/themes/oblique/fonts/../fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular) format('svg');
        font-weight: normal;
        font-style: normal
    }
    Plugin Author Frank Goossens

    (@futtta)

    ah, webfonts by default are not CDN’ed by AO, except (as per the FAQ) when you use a filter to convince AO to do it anyhow;

    Why aren’t my fonts put on the CDN as well?

    Autoptimize supports this, but it is not enabled by default because non-local fonts might require some extra configuration. But if you have your cross-origin request policy in order, you can tell Autoptimize to put your fonts on the CDN by hooking into the API, setting autoptimize_filter_css_fonts_cdn to true this way;

    add_filter('autoptimize_filter_css_fonts_cdn',__return_true);

    hope this helps,
    frank

    Thread Starter Ravindran

    (@ravindran214)

    Sorry that I wasted your time. Somehow I attributed this towards not having protocol. Should’ve checked FAQ first. ??

    Your solution worked perfectly well. Thanks!!!

    Just curious. Any reason, not having this as an option in UI? (of course, with caution about CORS header etc.,)

    Plugin Author Frank Goossens

    (@futtta)

    Any reason, not having this as an option in UI?

    trying to keep the amount of options under control, really. I’d rather remove some of them instead of adding more ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘CDN and protocol independent URIs’ is closed to new replies.