Support » Plugin: WebP Express » Worked on staging but not working on production.

  • Resolved skunkworks

    (@skunkworks)


    Have the exact same site running on two different (yet identical servers)
    The only difference being that the production server is being cached by Cloudflare’s CDN whereas the staging site is not.

    Staging gets WebP images served in Chrome.
    Production gets JPGs.

    Conversion method is Gd extension and it’s operational and passes tests.

    Any ideas?

    I can share the URLs for both sites with the developer but I can’t post them here.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author rosell.dk

    (@roselldk)

    I will try out Cloudflare, and how to make it play with WebP Express – hopefully today.

    Thread Starter skunkworks

    (@skunkworks)

    Emailed you the URLs in question.

    Plugin Author rosell.dk

    (@roselldk)

    Hm. Haven’t received any email…

    Plugin Author rosell.dk

    (@roselldk)

    Got the email.

    And I have set up a WordPress using Cloudfront.

    The general issue here is: “How do I get WebP express to work with a CDN”. I have a FAQ item for that.

    In short, the challenge with CDN’s is that they generally needs to be configured in order for them to maintain two caches for each image url. If left unconfigured, they will generally only cache one image per url.

    For some CDN’s it is solved by “forwarding the Accept header”. Doing this will create separate caches for each Accept header encountered.

    The issue here can be stated: How do I configure Cloudfront CDN to work with WebP Express?

    With Cloudfront, you configure the CDN with Page Rules. The available rules are listed here: https://support.cloudflare.com/hc/en-us/articles/218411427

    Browsing the rules, I see there is a rule called “Cache Key”. It looks like this is the one we need. Unfortunately this rule is only available for Enterprise accounts.

    The setting is described in detail here:
    https://support.cloudflare.com/hc/en-us/articles/115004290387

    I’m not going to purchase an enterprise account to experiment with this setting.
    But by reading the docs, I do believe that using “Cache Key” setting will work. In the “What can be added to the custom cache key?” section, it says that “Header content – the full value of the particular header” can be used in the cache key. And that is exactly what we need. And the value must be the “Accept” header.

    Plugin Author rosell.dk

    (@roselldk)

    You can of course also simply disable Cloudfront caching for jpeg/png as one did here: https://community.cloudflare.com/t/serving-webp-correctly/13336/5

    Plugin Author rosell.dk

    (@roselldk)

    If you don’t want to upgrade to Enterprise, but do want to stay on Cloudfront, and don’t want to disable cloudfront caching, then what you need is to specify the webp variant in the HTML with the <picture> and <source> tags, like this:

    
    <picture>
      <source srcset="img/awesomeWebPImage.webp" type="image/webp">
      <source srcset="img/creakyOldJPEG.jpg" type="image/jpeg"> 
      <img src="img/creakyOldJPEG.jpg" alt="Alt Text!">
    </picture>
    

    The Ewww plugin has an option that changes all tags to picture tags like above. I have no plans of implementing such feature in WebP Express. I do however consider an option to store the generated webp files in same folder as original. Together with a bulk convert option and the option we already have to disable the rewriting, it will allow the syntax above to function.

    • This reply was modified 2 years, 7 months ago by rosell.dk.
    • This reply was modified 2 years, 7 months ago by rosell.dk.
    Plugin Author rosell.dk

    (@roselldk)

    I just discovered an amazing javascript library, which actually makes webp images display in those browsers that are not supposed to support webp.

    Its here:
    https://webpjs.appspot.com/

    With the library, images such as <img src="logo.webp"> works in Firefox 3.5+, Safari 4+, etc. Simply amazing.

    With that library, we get the benefit of smaller image files also for older browsers AND CDNs will not have to maintain separate caches – everybody gets webp.

    Of course changing the image urls to webp in HTML will be about as complex as changing to <picture> syntax. But we can do the .htaccess rewriting as now, except simply always redirect jpg/png to the webp, – whether or not the “Accept” header contains ‘image/webp’.

    How does that sound?
    I think it sounds like something worthy more exploration.

    Also see this topic:
    https://wordpress.org/support/topic/request-update/#post-11011561

    • This reply was modified 2 years, 7 months ago by rosell.dk.
    Plugin Author rosell.dk

    (@roselldk)

    Using the *wp-webp* plugin together with WebP Express does not work out of the box. It only selects images with URLs ending with “webp”. With WebP Express, the URLs for the webp images ends with jpg (or png).

    Some work is required, but it should certainly be possible

    Thread Starter skunkworks

    (@skunkworks)

    The Ewww plugin has an option that changes all tags to picture tags like above.

    Hmm I’ve never seen that option. Will investigate.

    I just discovered an amazing javascript library, which actually makes webp images display in those browsers that are not supposed to support webp.

    It seems to convert every image into base64 encoded, inline, images. So the images become part of the html. It also seems to struggle with cross origin files if the .htaccess isn’t set properly. For example see the last image at the bottom of the source’s page here but it does work here on CodePen because the hosted image location has an .htaccess file that contains the required code.

    It also won’t load images properly on localhost.

    Errors:

    XMLHttpRequest cannot load file:///Users/me/Desktop/webptest/webpfile2.webp due to access control checks.
    waitListProcess — Anonymous Script 1 (line 1:82752)
    startDecoding — Anonymous Script 1 (line 1:87006)
    onerror — Anonymous Script 1 (line 1:76593)

    Cross origin requests are only supported for HTTP.
    waitListProcess — Anonymous Script 1 (line 1:82752)
    startDecoding — Anonymous Script 1 (line 1:87006)
    onerror — Anonymous Script 1 (line 1:76593)

    • This reply was modified 2 years, 7 months ago by skunkworks.
    • This reply was modified 2 years, 7 months ago by skunkworks.
    Thread Starter skunkworks

    (@skunkworks)

    I’ve done more investigating about getting WebP files cached on Cloudflare’s CDN.

    There is a feature in paid Cloudflare accounts (Starting at the “Pro” level plan @ $20/month) called “Polish”. Polish includes a WebP conversion (Done in the cloud) and will serve to compatible browsers. These .webp files will also be cached by their CDN. (I put the question to Cloudflare and one of their engineers has confirmed this.)

    So basically WebP Express will work for users that are not using the free Cloudflare plan unless image caching is turned off (Undesirable).
    If a user is on a paid Cloudflare plan, this plugin wouldn’t be needed if the “Polish” feature is turned on as “WebP” is checked.

    Plugin Author rosell.dk

    (@roselldk)

    Yes, sounds right. I could even add that handling webp conversion (and other image optimizations) on the CDN is where it makes most sense. This plugin has its place, because such CDN features don’t come for free (yet). And perhaps, it is easier to set up (for those not using CDN)

    Plugin Author rosell.dk

    (@roselldk)

    I’l add a section to the FAQ summarizing these findings. Thanks

    Plugin Author rosell.dk

    (@roselldk)

    Alternatively, you can set up another CDN (on another provider), which you just use for handling the images.

    1. Setup the CDN and configure it to forward the *Accept header*
    2. Install a WordPress plugin that points images to that CDN.

    You need to configure that CDN to forward the *Accept header*.

    I’m using Amazon Cloudfront. Their admin interface is a bit confusing, but the pricing is perfect. I have five sites running and pay less than a dollar a month. Many if not all their competitors have a minimum amount. They use all kind of weird pricing systems to cover this up. Keycdn for example has their credits system, which amounts to a minimum amount of $49

    Plugin Author rosell.dk

    (@roselldk)

    I have now added a “I am on Cloudfront” section in the FAQ

    Plugin Author rosell.dk

    (@roselldk)

    Marking as resolved

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Worked on staging but not working on production.’ is closed to new replies.