Learn about Centmin Mod LEMP Stack today
Become a Member

Playing with EWWW Image Optimizer Wordpress Plugin

Discussion in 'Blogs & CMS usage' started by eva2000, Aug 15, 2017.

  1. eva2000

    eva2000 Administrator Staff Member

    54,906
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    2:18 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    tried purging entire cloudflare cache first ?

     
  2. upgrade81

    upgrade81 Member

    295
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:18 AM
    1.17
    10.3
    I don't use Cloudflare proxy.
    I only use the DNS function.
     
  3. eva2000

    eva2000 Administrator Staff Member

    54,906
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    2:18 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Indeed seems Nginx webP isn't working for Cloudflare DNS only mode so will need to investigate.
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,906
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    2:18 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    If you change /usr/local/nginx/conf/webp.conf to below and restart nginx server, does Cloudflare DNS only mode allow webP to work ?
    Code (Text):
    map $http_accept $webp_extension {
        default "";
        "~*webp" ".webp";
    }
    
    map $http_cf_cache_status $webp_extension {
        default  "";
        ""       ".webp";
    }
    

    But that might not work properly as the 2nd map will override and ignore whether a browser supports Accept: image/webp mime type. So will need probably a 3rd nginx map to valdiate both $http_accept has image/webp + where $http_cf_cache_status is empty. Something like probably webp.conf include file
    Code (Text):
    map $http_accept $webpok {
        default   0;
        "~*webp"  1;
    }
    
    map $http_cf_cache_status $iscf {
        default   1;
        ""        0;
    }
    
    map $webpok$iscf $webp_extension {
      11          "";
      10          ".webp";
      01          "";
      00          "";
    }

    So when web browser supports HTTP Accept header with image/webp mime type set $webpok variable to value of 1 and when cf-cache-status header exists, set $iscf variable to 1 and if doesn't exist set $iscf variable to 0

    Then if $webpok$iscf combined variables have a value of 10 for $webpok = 1 and $iscf = 0, it means web browser supports Accept header with image/webp for request header indicating webP browser support + when cf-cache-status doesn't exist $iscf = 0 = enable Nginx webP support by assign $webp_extension variable with value of .webp for extension appending to original image name
     
  5. upgrade81

    upgrade81 Member

    295
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:18 AM
    1.17
    10.3
    Only if I delete this part and restart nginx, does it work.

    Code:
    map $http_cf_cache_status $webp_extension {
        default "";
    }
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,906
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    2:18 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    changing webp.conf to below doesn't work ?
    Code (Text):
    map $http_accept $webpok {
       default   0;
       "~*webp"  1;
    }
    
    map $http_cf_cache_status $iscf {
       default   1;
       ""        0;
    }
    
    map $webpok$iscf $webp_extension {
      11          "";
      10          ".webp";
      01          "";
      00          "";
    }
    
     
  7. upgrade81

    upgrade81 Member

    295
    17
    18
    Sep 5, 2016
    CH
    Ratings:
    +30
    Local Time:
    5:18 AM
    1.17
    10.3
    Yes, this works correctly.
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,906
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    2:18 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Great updated 123.09beta01 with webp.conf changes now as well so folks can run cmupdate and run centmin.sh menu to auto update webp.conf include file.

    Also updated official site instructions at Nginx Serving WebP Images Conditionally Demo
     
  9. eva2000

    eva2000 Administrator Staff Member

    54,906
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    2:18 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Updated 123.09beta01's Centmin Mod Nginx webP support at Beta Branch - update webp.conf for cloudflare compatibility in 123.09beta01

    Allow proper compatibility with Cloudflare Proxy and DNS only modes so when Cloudflare Proxy CDN mode detected disable Centmin Mod Nginx webP due to Cloudflare cache not supporting HTTP Vary header and when Cloudflare DNS only mode detected or in absence of Cloudflare, enable Centmin Mod Nginx webP