• By default, it seems that if you enable CDN that this plugin assumes the files you selected to be on the CDN are available on the CDN. This works for the most part, however when I have a client uploading new images, I do not want to have them go to the performance tab every time to upload changes to the CDN.

    I notice there is an “Automatically Upload Changes” option, however this currently defaults to 1 hour. Cranking that up to every minute would solve my problem, however sometimes there will be weeks or months without ever uploading a new image, and a lot of resources are wasted checking for new files every minute.

    Is there a way to have the plugin do a quick check to see if the image exists, and if not, fall back to the local copy? Can this be done in htaccess?

    Thanks!

    https://www.ads-software.com/extend/plugins/w3-total-cache/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Chad Huntley

    (@chuntley)

    Bump

    Thread Starter Chad Huntley

    (@chuntley)

    Ended up coming up with a javascript solution for myself:

    $(window).load(function() {
        $('img').each(function() {
            if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
                var source = this.src;
                this.src = source.replace(document.location.protocol + '://cdn.',document.location.protocol + '://');
            }
        });
    });

    This only works if your domain is non-www, and your cdn is formatted as “cdn.mydomain.com”. This looks through all images, checks if the CDN version loaded, if not, falls back to mydomain.com. Now I can turn down the Amazon S3 sync to once a day, and there are no noticeable performance issues.

    Thread Starter Chad Huntley

    (@chuntley)

    Alright did another big update to this script to include links. Here is a write up: https://elementdesignllc.com/2013/06/w3-total-cache-cdn-to-local-fallback/

    hard to believe you’re the only person with this issue. I appreciate you sharing your work on it. I keep turning off CDN although I could really use it because some of my images are uploaded through external scripts and aren’t stored in the media library at all. It seems extremely hit and miss whether these images get pushed out to the cloud. Anyway hoping your solution will work for me as well, gotta dig in and see how you’re doing it. Anyway just wanted to let you know there’s lots of need for this and I appreciate your work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘CDN to Local Fallback’ is closed to new replies.