Want more timely Centmin Mod News Updates?
Become a Member

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

    34
    6
    8
    Jun 21, 2020
    Ratings:
    +11
    Local Time:
    5:06 AM
    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,648
    10,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,435
    Local Time:
    2:06 PM
    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

    34
    6
    8
    Jun 21, 2020
    Ratings:
    +11
    Local Time:
    5:06 AM
    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,648
    10,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,435
    Local Time:
    2:06 PM
    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/*
     
  5. ct_roy

    ct_roy Premium Member Premium Member

    34
    6
    8
    Jun 21, 2020
    Ratings:
    +11
    Local Time:
    5:06 AM
    1.17.10
    10.3.22
    Interesting.
    I just did another clean WP install - (I chose Cache Enabler as my caching method) and I didn't install any other plugins and that code block is active by default.
    Once again I had to go in and comment out the same 2 lines.

    Looking at that code block, it's applying the Vary "accept" and no-transform headers to all jpegs, gifs,pngs (since I have no webp's at all) which I think is the issue.

    Does choosing the Cache Enabler cache method via centmin menu options 22 trigger this code block to be activated?
     
  6. eva2000

    eva2000 Administrator Staff Member

    46,648
    10,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +16,435
    Local Time:
    2:06 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    it's a default location context for all wpsecure_domain.com.conf include files

    but I see how this setting
    Code (Text):
    add_header Cache-Control "public, no-transform";
    

    could be problematic if you aren't using webP on Centmin Mod Nginx side for Cloudflare Polish

    Seems like a bug I need to fix :)
     
  7. ct_roy

    ct_roy Premium Member Premium Member

    34
    6
    8
    Jun 21, 2020
    Ratings:
    +11
    Local Time:
    5:06 AM
    1.17.10
    10.3.22
    that what I was thinking :)