[Hummingbird Pro] Use CDN for 3rd party assets

0

Hello,

I would be nice to have this features integrated in Hummingbird.
By default CDN is only used for assets stored on the server (code, image…) but some assets are brought by other services (ads, frames…).
Withou Cldouflare you can use CDN for these external assets, I would be glad to have that with HB

  • Adam
    • Support Gorilla

    Hi Antoine

    I hope you’re well today!

    The CDN that you can enable in Hummingbird is only used for storing JS/CSS while images can be served via Smush CDN (which in fact is a separate feature and CDN technically speaking) but you are right – both can only handle resources that are “local to the site”.

    “Intercepting” and storing “external”/3rd-party assets this way isn’t as simple as it may seem, though. With assets “local to the site” we make use of proper WP-core hooks to to change how site loads these assets and we only need to upload processed files to our CDN.

    With 3rd-party assets not only we’d need to first download such assets (before being able to push them to our CND) but also changing references to those assets on site may not be as simple and/or as efficient because they aren’t always added via WP’s “enqueue”/”register” functions.

    With that in mind, I’m not saying it’s not doable.

    Hummingbird is already capable to e.g. optimize font files delivery (and those are often external resources) and do async load of some 3rd-party resource – provided that they are registered via WP enqueue/register core functions. So that’s a start.

    Making it host 3rd-party assets – at least some (again, those registered via core WP functions) – could technically be possible but will require quite a lot of complex additional development to the plugin and needs to be researched first carefully and in details.

    I think, let’s keep this feature suggestion ticket open and see about other Members feedback. It’s surely an interesting idea and we listen to your (Members) feedback with great attention so let’s see if more Members would like to have Hummingbird support such solution.

    Best regards,
    Adam

  • Tony G
    • Mr. LetsFixTheWorld

    I hadn’t even considered this aspect of optimization but it makes sense. Hummingbird is already somewhat unique in its complexity. I think this feature “fits” with that.

    Please help me to understand this better. Let’s say a 3rd-party asset is an image, maybe an ad. It’s possible that this asset is already served from a CDN. It’s possible that the asset is dynamic and we don’t want a CDN to cache it. Am I understanding the request and challenges on this?

    What other 3rd-party assets might be offered by a CDN? : Files for download? IFrame content? Again, if the asset is dynamic, private, or licensed, we wouldn’t want to push it up to a CDN for general delivery.

    And would the purpose of caching assets in CDN be to optimize delivery of content where we know the remote 3rd-party is not already doing so?

    In summary, while I see some benefits, I also see that it could be a procedural challenge to identify and categorize potential assets for export to CDN. In exactly the same way that we need to monitor scripts, and whether a specific Hummingbird optimization hurts or helps, it seems we would need to monitor these other assets. That is, get the average Time To Load for an asset over a period of time, target it in Hummingbird for CDN, then calculate a new TTL over a period of time to check the efficacy.

    Am I understanding this?

    Thanks!

    • Adam
      • Support Gorilla

      Hi Tony G

      I think your response was more to Antoine than me but you’ve actually raised some valid points here and after re-reading initial post, I think I should add-up something to my previous reply:

      Antoine mentioned, I quote, “some assets are brought by other services (ads, frames…).“. In my response I mostly focused on assets such as JS and CSS and I think that’s pretty much all we could and – if it comes to that in future – should focus in plugin too.

      “Ads” and “frames” that’s usually a lot more dynamically injected content than just a JS script and technically handling it on plugin level wouldn’t be easy at all, could result in more issues (with such ads and frames) than benefits and in general – isn’t really a “thing”.

      If there’s a JS or CSS asset – or even something like font file – that’s properly enqueued in WP or it’s included in some more “static” way (even if it’s e.g. “script” or “link” or similar tag “hard coded” in page template) then it’s probably something that could possibly be downloaded from source and stored and served locally or pushed to CDN. Whether it’s worth it or not – that’s a whole different story and often would depend on particular case.

      But serving “ad” or “frame” from CDN would mean not only seriously alternating (probably in real time or in cached files) source code of already rendered page but also downloading a lot of various staff and somehow “stitching it together” locally first to make it even work. Which often may not even be possible due to some dependencies and internal relations of such ad/frame source that can only be met on the source location where it is served from by default.

      So to that part, I’d say: no, it’s not that easy (if doable in a reliable and performance-beneficial way at all) and nearly for sure just “not worth it”, in that sense that amount and complexity of the work that would have to be done to make it work at all together with quite likely rather slight, if any at all, performance boost – those would way outweigh possible benefits.

      If we focus on JS/CSS (and things like fonts and “statically linked/included” images maybe) – then yes, this may be something worth looking into, as I already mentioned before.

      And to add-up to that all: it’s worth remembering that not all CDNs are the same. There’s a huge difference in a way CDN such as CloudFlare and similar work and CDN such as Hummingbird/Smush CDN work (or, for that matter, e.g. built-in GoDaddy’s CDN).

      CloudFlare is basically a DNS-based proxy that works “in front” of the site and can easily intercept various requests and cache responses to these requests and does it all in an environment that’s completely separate form the site and its server.

      CDNs such as ours , GoDaddy’s built-in one and a few other popular solutions work more in “offload” fashion and kind of “behind” the site and they also require some (quite complex actually) scripts (plugin) to handle assets “transfers” and handling and those work “inside the site” – which itself means that when adding any new features we not only need to assets possible performance benefits that this feature may bring in but also possible additional resource usage that implementation of such feature may bring to the site due to complexity of the code needed.

      So all in all, it’s really not as simple subject as it may seem goes way further than just “grabbing asset and uploading it to CDN” :)

      Best regards,
      Adam

      • Tony G
        • Mr. LetsFixTheWorld

        Adam – We’re completely on the same page. This is why I asked the questions:

        Let’s say a 3rd-party asset is … maybe an ad. … It’s possible that the asset is dynamic and we don’t want a CDN to cache it. … Again, if the asset is dynamic, private, or licensed, we wouldn’t want to push it up to a CDN for general delivery.

        I agree that for some assets the per-transaction performance benefits, if any, would be far outweighed by the cost to attempt development of something like this. Ads and other third-party content might include referral codes, user IDs, or personal content that almost never make sense to cache in the browser or in a CDN.

        Antoine says Cloudflare caches that. I’d ask “Why?”. The payload for an ad is usually small enough that pulling from a CDN rather than the originator is overkill. Aren’t ads usually flagged for no-cache anyway? So a content provider probably should not cache ads or other third-party data for business and technical reasons, even if a company like Cloudflare supports it.

        But there might be other assets that would benefit from inclusion without much change to the existing JS/CSS handling. I’d still like to know more about what kind of resources Antoine has in mind. I feel like I might not be understanding something of value.

        Best,
        T