WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
CDN to Local Fallback (5 posts)

  1. Chad Huntley
    Member
    Posted 1 year ago #

    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!

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. Chad Huntley
    Member
    Posted 1 year ago #

    Bump

  3. Chad Huntley
    Member
    Posted 1 year ago #

    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.

  4. Chad Huntley
    Member
    Posted 1 year ago #

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

  5. FurySting
    Member
    Posted 12 months ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic