Discover Centmin Mod today
Register Now

Wordpress Cloudflare Polish issues

Discussion in 'Blogs & CMS usage' started by ct_roy, Feb 18, 2021.

Tags:
  1. ct_roy

    ct_roy Premium Member Premium Member

    31
    6
    8
    Jun 21, 2020
    Ratings:
    +11
    Local Time:
    11:45 PM
    1.17.10
    10.3.22
    So I've enabled CF Polish on one of my test subdomains and noticed that Polish wasn't doing it's thing.
    After digging around the cmm nginx config files I noticed that all images had the "no-transform" header (in addition to the Vary "accept" header).
    Further digging narrowed this down to wpsecure_mydomain.com.conf

    I made a couple of tweaks as follows:
    - commenting out the no-transform and Vary "Accept" headers
    - adding gif to the image list
    - extending the expires to 365d (to keep Google Pagespeed Insights happy)

    Code:
    # WebP extension support if you are converting /uploads images to webp
    location ~ ^/wp-content/uploads/ {
      #pagespeed off;
      #pagespeed unplugged;
      #autoindex on;
      #add_header X-Robots-Tag "noindex, nofollow";
      location ~* ^/wp-content/uploads/(.+/)?(.+)\.(gif|png|jpe?g)$ {
        expires 365d;
        #add_header Vary "Accept";
        #add_header Cache-Control "public, no-transform";
        add_header Cache-Control "public";
        try_files $uri$webp_extension $uri =404;
      }
    }
    CMM version:
    123.09beta01.b616

    With my tweaks above, webp's are being generated where relevant (and smaller than the original source).

    I'm guessing I shouldn't need to do this?
    I know CF doesn't support vary and you've got code in place that detects CF - but does that also impact a pro account as per above?
     
  2. eva2000

    eva2000 Administrator Staff Member

    46,180
    10,499
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,278
    Local Time:
    9:45 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    Yes CF all paid and free accounts do not support webp generated at Centmin Mod origin if the webp image uses same extensions as non-webp image. So for CF Polish to work you need to disable webp serving on Centmin Mod origin side.
     
  3. ct_roy

    ct_roy Premium Member Premium Member

    31
    6
    8
    Jun 21, 2020
    Ratings:
    +11
    Local Time:
    11:45 PM
    1.17.10
    10.3.22
    In my scenario I didn't *think* I had enabled webp serving! How do I disable it and I'll check if I had enabled it at some point.
     
  4. eva2000

    eva2000 Administrator Staff Member

    46,180
    10,499
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,278
    Local Time:
    9:45 AM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    with this in place
    Code (Text):
    # WebP extension support if you are converting /uploads images to webp
    location ~ ^/wp-content/uploads/ {
      #pagespeed off;
      #pagespeed unplugged;
      #autoindex on;
      #add_header X-Robots-Tag "noindex, nofollow";
      location ~* ^/wp-content/uploads/(.+/)?(.+)\.(gif|png|jpe?g)$ {
       expires 365d;
       #add_header Vary "Accept";
       #add_header Cache-Control "public, no-transform";
       add_header Cache-Control "public";
       try_files $uri$webp_extension $uri =404;
      }
    }
    

    it will auto enable if you installed a Wordpress plugin to do webp conversion on the server side with format of image.jpg.webp or image.png.webp in /wp-contents/uploads/*