Learn about Centmin Mod LEMP Stack today
Become a Member

Wordpress Installing WebP Express Wordpress Plugin on Centmin Mod Nginx

Discussion in 'Blogs & CMS usage' started by eva2000, May 11, 2019.

  1. Shirkit

    Shirkit New Member

    20
    4
    3
    Feb 6, 2019
    Ratings:
    +7
    Local Time:
    7:26 PM
    No I literally mean there's a new 'Tests' module inside the plugin configuration: https://imgur.com/tzmWlEy


    I know I only need one of the libraries to work, but the tests are failing.
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,107
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    8:26 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You mean those 3x redirection rule tests ? They won't work they test .htaccess apache file. Nginx doesn't support Apache's .htaccess.
     
  3. zkylizer

    zkylizer New Member

    16
    0
    1
    Jun 5, 2019
    Ratings:
    +2
    Local Time:
    5:26 AM
    1.17.0
    MariaDB 10
    if using webp express still need image optimize plugin or not ?
    because in webp expresss already has feature reduce image quality
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,107
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    8:26 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah you can just use webp express plugin
     
  5. zkylizer

    zkylizer New Member

    16
    0
    1
    Jun 5, 2019
    Ratings:
    +2
    Local Time:
    5:26 AM
    1.17.0
    MariaDB 10
    1. are safe removing original .jpg or .png after converted to .webp ?

    2. and how i can fix multiple vary ?
    vary Accept-Encoding ( how to remove this default vary )
    vary Accept

    3. if i using add_header X-Content-Type-Options "nosniff" from server { will apply to all type file css, js, html, etc? or i still need uncomment in /usr/local/nginx/conf/staticfiles-hsts.conf
     
    Last edited: Apr 19, 2020
  6. eva2000

    eva2000 Administrator Staff Member

    54,107
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    8:26 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    no you need original image + webp always as not all browsers support webP so if you remove original image, non-webP supported browsers will have broken images

    webP saves image size for clients whose browser supports webP. webP does not save disk space usage for the web site, it increases it as it has to store both original image + webP image which will increase disk usage.

    those are normal Accept and Accept-Encoding are different not the same
    You have to tread what nosniff does and decide for yourself if it's suited to your own web site Security Headers - X-Content-Type: nosniff | Sucuri Docs and you can check which requests get nosniff header by inspecting it in web browser dev tools network tab for header responses or via curl i.e.
    Code (Text):
    curl -I https://yourdomain.com/path/to/image/or/css/jss

    example
    Code (Text):
    curl -I https://www.cloudflare.com
    HTTP/2 200
    date: Sun, 19 Apr 2020 09:21:34 GMT
    content-type: text/html; charset=utf-8
    set-cookie: __cfduid=dedfdfd2735c84edf7a9403822b7880b01587288094; expires=Tue, 19-May-20 09:21:34 GMT; path=/; domain=.www.cloudflare.com; HttpOnly; SameSite=Lax; Secure
    cf-ray: 58658e5d4d508552-ORD
    age: 51
    cache-control: public, s-max-age=30
    strict-transport-security: max-age=31536000
    vary: Accept-Encoding
    cf-cache-status: HIT
    expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
    x-content-type-options: nosniff
    x-frame-options: SAMEORIGIN
    x-xss-protection: 1; mode=block
    server: cloudflare
    alt-svc: h3-27=":443"; ma=86400, h3-25=":443"; ma=86400, h3-24=":443"; ma=86400, h3-23=":443"; ma=86400
    cf-request-id: 0233574e4f00008552bb37e200000001
    

    the add_header will apply to whichever context the line is added to within a location{], server{} or specific file extension match location{} context. So answer is it depends on where you use add_header directive as to where it is applied
     
  7. skringjer

    skringjer NoobMaster69

    208
    26
    28
    Apr 21, 2019
    Ratings:
    +43
    Local Time:
    3:26 AM
    Nginx 1.21.6
    MariaDB 10.3.x
    Okay so i followed the guide and everything is working properly. Screenshot

    I wanted to ask why is the original image loaded in JPG or PNG

    Sorry i still haven't properly studied this, i know we need original files for unsupported browsers.

    But in supported browsers it loads all the images originally when i inspect element.
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,107
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    8:26 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    that is normal - image extension is .jpg or .png but mime time is webP when converted
     
  9. ct_roy

    ct_roy Premium Member Premium Member

    55
    9
    8
    Jun 21, 2020
    Ratings:
    +17
    Local Time:
    10:26 PM
    1.17.10
    10.3.22
    @eva2000
    WebP express is functioning great for me overall with your config as per page 1 of this thread.
    Just wondering if anything can be done about the various errors/warnings that crop up in the plugins live tests.

    None of these actually stop me using the plugin as the bulk convertor catches anything historic (and works fine with your whitelist exception). and the convert on upload catches anything new.

    But I'm guessing some might get missed with updates to theme images (and forgetting to re-run a bulk conversion) so it would be nice to have the plugins fallbacks work.

    I'm guessing some additional whitelist rules would be needed for the on demand and realizor scripts per their recommended nginx config (as per below).

    Any thoughts on this?


    Code:
    # WebP Express rules
    # --------------------
    location ~* ^/?wp-content/.*\.(png|jpe?g)$ {
      add_header Vary Accept;
      expires 365d;
      if ($http_accept !~* "webp"){
        break;
      }
      try_files
        /wp-content/webp-express/webp-images/doc-root/$uri.webp
        $uri.webp
        /wp-content/plugins/webp-express/wod/webp-on-demand.php?xsource=x$request_filename&wp-content=wp-content
        ;
    }
    
    # Route requests for non-existing webps to the converter
    location ~* ^/?wp-content/.*\.(png|jpe?g)\.webp$ {
        try_files
          $uri
          /wp-content/plugins/webp-express/wod/webp-realizer.php?xdestination=x$request_filename&wp-content=wp-content
          ;
    }
    # ------------------- (WebP Express rules ends here)

    e.g.

    [​IMG]

    [​IMG]

    Redirection error
    [​IMG]

    Realizer error
    [​IMG]
     
  10. Shirkit

    Shirkit New Member

    20
    4
    3
    Feb 6, 2019
    Ratings:
    +7
    Local Time:
    7:26 PM
    On my end the tests always end up failing, despite the plugin working correctly. Try checking if it's working despite the tests.
     
  11. Tinkerd10

    Tinkerd10 Member

    30
    3
    8
    Sep 28, 2016
    Ratings:
    +15
    Local Time:
    11:26 PM
    1.25.1
    10.11
    Hi

    In this version i'm currently using it has more options, in particularly
    You need to change Destination structure to: image root.
    Otherwise it won't work, as you mentioned both images need to be on the same folder.

    Destination structure:
    This setting determines how the converted files are structured within the folder that WebP Express uses for storing webp images (from here on called "the cache root")

    "document root"
    When "document root" is selected, the webp images will be stored in:
    [cache root]/doc-root/[relative path of source image, from document root].

    "image roots"
    A Wordpress site has images stored in different locations. Uploaded files are for example stored in the uploads folder, which is usually - but not always - located in the "wp-content" folder. I call the uploads folder an "image root". Other roots are: "themes", "plugins", "wp-content" and "index". When the "image roots" setting is selected, the webp files are stored in a structure that mirrors the relative path of the source image within its image root. For "uploads", that location is:
    [cache root]/uploads/[relative path of source image, from uploads root].
    More generally we have:
    [cache root]/[image root]/[relative path of source image, from its image root].

    Which option is best?
    Well, in most cases it does not matter. However, there are hosts out there that have set the document root up incorrectly, so I would generally recommend "Image roots". On Nginx, I however recommend "Document root", as it requires fewer rewrite rules.​
     
  12. eva2000

    eva2000 Administrator Staff Member

    54,107
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    8:26 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  13. Shirkit

    Shirkit New Member

    20
    4
    3
    Feb 6, 2019
    Ratings:
    +7
    Local Time:
    7:26 PM
    Hello @eva2000 I'm struggling to have my WebP images cached.

    I've followed your guide on Wordpress Cache Enabler Advanced Full Page Caching Guide - Centmin Mod Blog to setup with Cloudflare (although I have in development mode, I have set to respect expires header from the origin)

    Firefox shows as having a expires header on my WebP images for 30d, but WebPageTest claims there's none, and I tend to believe more on tools these days WebPageTest do you have any insights on this? Also, here's my nginx -T output #include /usr/local/nginx/conf/errorpage.conf; include /usr/local/nginx/con - Pastebin.com

    Also, my WOFF2 fonts from Use Any Font plugin that's on /wp-content/uploads/useanyfont/ have no expires header, and I imagine that I've done something wrong because I could swear it should have a cache control header on /uploads/ folder

    Anyways, thank you
     
  14. eva2000

    eva2000 Administrator Staff Member

    54,107
    12,179
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,739
    Local Time:
    8:26 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    You using some plugin to create webp images on origin nginx side? As I see images .jpg.webp extension which is in WordPress /upload sub directories so nginx vhost does not set expires headers that deep in the parent directory. Easiest way is to turn off origin WordPress webp conversion and just use Cloudflare paid plans Polish webp. Even WordPress performance team has delayed webp support as it increases disk usage for installations. Using Cloudflare Polish webp saves disk space and gives smaller images

    ok found that news from Wordpress https://wptavern.com/webp-by-defaul...new-objections-from-wordpress-lead-developers

     
    Last edited: Aug 27, 2022