Welcome to Centmin Mod Community
Become a Member

Nginx PageSpeed Wordpress Nginx PageSpeed WordPress with Redis Cache

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by EckyBrazzz, Mar 26, 2019.

  1. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    Please fill in any relevant information that applies to you:
    • CentOS Version:CentOS 7.5 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: 1.15.9
    • PHP Version Installed: 7.3.3
    • MariaDB MySQL Version Installed: 10.3.xx
    • When was last time updated Centmin Mod code base ? : CronJob
    • Persistent Config:
      Code (Text):
      MARCH_TARGETNATIVE='n'
      LETSENCRYPT_DETECT='y'
      NGXDYNAMIC_BROTLI='y'
      NGINX_LIBBROTLI='y'
      ENABLE_MARIADBTENTWOUPGRADE='y'
      NGXDYNAMIC_BROTLI='y'
      NGINX_LIBBROTLI='y'
      PHP_PGO='y'
      NGINX_PAGESPEEDGITMASTER='n'
      NGXDYNAMIC_NGXPAGESPEED='y'
      NGINX_PAGESPEED='y'
      
    Well, I had a bad experiance with the WordPress Installer with option 2 (Redis).
    Every time I made changes to my theme it worked perfect. Even purging the cache worked fine, together with PageSpeed and CloudFlare. Loading time about 300ms for then site.
    before_pagespeed_redis.png
    But missing some caching in PageSpeed but resolved it with these extra lines
    Code:
    pagespeed on;
    pagespeed RedisServer "localhost:6379";
    pagespeed LRUCacheKbPerProcess     8192;
    pagespeed LRUCacheByteLimit        16384;
    pagespeed CreateSharedMemoryMetadataCache "/var/cache/pagespeed/" 51200;
    
    The resul of this change was directly notable into the PageSpeed Admin page
    pagespeedchachemisses.png

    I hope that the above could help some other persons who want to use PageSpeed with Redis Cache, but this option did not work with my theme.

    My Dbase part of the theme entries got deleted when the CLI cron runs (at least that is what i think because I got the email and after that my site was cleaned), so I had to start over again and again to find this out. Other parts like created posts ect were kept intact, only the theme settings where missing/deleted from the Dbase.

    Output of the CLI-Cron
    Code:
    /home/nginx/domains/domain.com/public
    update wp-cli
    2019-03-26 00:02:06 URL:https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar [5421617/5421617] -> "/usr/bin/wp" [1]
    OS:    Linux 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64
    Shell:    /bin/sh
    PHP binary:    /usr/local/bin/php
    PHP version:    7.3.3
    php.ini used:    /usr/local/lib/php.ini
    WP-CLI root dir:    phar://wp-cli.phar/vendor/wp-cli/wp-cli
    WP-CLI vendor dir:    phar://wp-cli.phar/vendor
    WP_CLI phar path:    /home/nginx/domains/domain.com/public
    WP-CLI packages dir:    /root/.wp-cli/packages/
    WP-CLI global config:  
    WP-CLI project config:  
    WP-CLI version:    2.1.0
    PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/my-wp-translate/includes/class-my-wp-translate-po-parser.php on line 167
    Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/my-wp-translate/includes/class-my-wp-translate-po-parser.php on line 167 PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 80
    Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 80 PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 84
    Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 84 PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 88
    Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 88
    13 installed plugins:
      A cdn-enabler                1.0.8
      A disable-xml-rpc            1.0.1
      A cookie-law-info            1.7.6
      A mythemeshop-connect        2.0.14
      A my-wp-translate            1.0.8
      A nginx-helper               2.0.2
      A sucuri-scanner             1.8.20
      A thirstyaffiliates          3.7
      A tinymce-advanced           5.1.0
      A sitepress-multilingual-cms 4.2.4.1
      A wp-review-pro              3.3.4
      A wp-subscribe-pro           1.5.31
      A wordpress-seo-premium      9.7
    
    Legend: A = Active
    PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/my-wp-translate/includes/class-my-wp-translate-po-parser.php on line 167
    Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/my-wp-translate/includes/class-my-wp-translate-po-parser.php on line 167 PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 80
    Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 80 PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 84
    Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 84 PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 88
    Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/nginx/domains/domain.com/public/wp-content/plugins/wp-review-pro/admin/import/class-wp-review-importer-gd-rating-system.php on line 88
    Success: Plugin already updated.
    Also with this theme when I did a curl -I Website Domains Names & Hosting | Domain.com it showed that pagespeed was active, I made the same test on another server and it gave me the same result.
    On sites like HTTP Status Codes Checker ~ Server Header Response Code Checking Tool there was no entry of the pagespeed only when I added ?ModPageSpeed=on to the domain that had to be checked.

    Another strange thing was that on the browser I was working to edit the theme and looked at the final result and had a look at the pagesource it showed that PageSpeed was active.
    In a private window it was different. No pagespeed, only when adding the ?ModPageSpeed=on to the domain.

    Anybody else with this same problem with PageSpeed and Redis Cache?
     
  2. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    sounds like some of wordpress plugins aren't fully PHP 7.3 compatible. Tried downgrading to PHP 7.2 ?

    centmin mod ngx_pagespeed only really has been tested with memcached server so not sure how using redis server fairs myself.
     
  3. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    Found that solution on the Plesk forum. Resolved - Redis and ngx_pagespeed configuration

    But with that configuration I got some errors when putting the configuration into the pagespeed.conf file
    Code:
    [13:22][root@server ~]# nginx -t
    nginx: [warn] [ngx_pagespeed 1.13.35.2-0] [0326/133949:WARNING:google_message_handler.cc(56)] 'CreateSharedMemoryMetadataCache' is global and is ignored at this scope
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    [13:39][root@server3 ~]# service nginx restart
    Restarting nginx (via systemctl):                          [  OK  ]
    
    Putting this directly into the nginx.conf file and the error was gone
    Code:
    #more_clear_headers "X-Powered-By";
    
    pagespeed on;
    pagespeed RedisServer "localhost:6379";
    pagespeed LRUCacheKbPerProcess     8192;
    pagespeed LRUCacheByteLimit        16384;
    pagespeed CreateSharedMemoryMetadataCache "/var/pagespeed/" 51200;
    
    
    # uncomment cloudflare.conf include if using cloudflare for
    
    But the /var/pagespeed dir was not created.

    Resolved the issue

    Code:
    /home/nginx/domains/domain.com/public
    update wp-cli
    2019-03-26 08:05:21 URL:https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar [5421617/5421617] -> "/usr/bin/wp" [1]
    OS:    Linux 3.10.0-957.10.1.el7.x86_64 #1 SMP Mon Mar 18 15:06:45 UTC 2019 x86_64
    Shell:    /bin/sh
    PHP binary:    /usr/local/bin/php
    PHP version:    7.2.16
    php.ini used:    /usr/local/lib/php.ini
    WP-CLI root dir:    phar://wp-cli.phar/vendor/wp-cli/wp-cli
    WP-CLI vendor dir:    phar://wp-cli.phar/vendor
    WP_CLI phar path:    /home/nginx/domains/domain.com/public
    WP-CLI packages dir:    /root/.wp-cli/packages/
    WP-CLI global config:
    WP-CLI project config:
    WP-CLI version:    2.1.0
    10 installed plugins:
      A cdn-enabler         1.0.8
      A disable-xml-rpc     1.0.1
      A mythemeshop-connect 2.0.14
      A my-wp-translate     1.0.8
      A nginx-helper        2.0.2
      A sucuri-scanner      1.8.20
      A thirstyaffiliates   3.7
      A tinymce-advanced    5.1.0
      A wp-review-pro       3.3.4
      A wp-subscribe-pro    1.5.31
    
    Legend: A = Active
    Success: Plugin already updated.
    Created a new site and downloaded the demo data that comes with the theme to test. The first hours the demo data was there, even after purg cach but after checking it again and ´purging the cach this morning it was all gone again.

    Gona stop my experiment with redis cache together with pagespeed with this theme, just made a little step forward to get it work. Go for Memcache as eva2000 said before that these are tested and working in centmin.

    About PageSpeed: After a cache purge the first time the page loads it´s with pagespeed enabled, the second time not. When adding Website Domains Names & Hosting | Domain.com?ModPageSpeed=on it works again. (PageSpeed, not the demo data of the theme). I am willing to do some more testing on another server, but for the moment I´m running out of time. Have to prepair and create a lot of domains with the same theme.

    The Redis external cache is supported with pagespeed. See this link PageSpeed System Integration
     
    Last edited: Mar 27, 2019
  4. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    centmin mod pagegspeed conf has an include file for that https://centminmod.com/nginx_ngx_pagespeed.html at /usr/local/nginx/conf/pagespeedadmin.conf included in /usr/local/nginx/conf/nginx.conf

    with command shortcut to it = pscontrol admin which invokes nano editor to that include file
    Code (Text):
     pscontrol handler
     pscontrol edit
     pscontrol editstats
     pscontrol on
     pscontrol off
     pscontrol statson
     pscontrol statsoff
     pscontrol admin
    

    purging which cache ? nginx level redis cache that comes with centmin.sh menu option 22 or purging cache for ngx_pagespeed ? it could be that both are trying to use redis server default database = 0, so when you purge the cache it maybe purging database = 0 in redis server. If you can try setting different database number instead of 1 use one the other default redis databases 1-14 (default has 15 available from 0-14).

    PageSpeed System Integration
     
  5. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    I purged the cache with the centmin.sh menu op 22 and in the Nginx helper I have set the caching method to Redis cache.

    I have entered the setting into pscontrol admin, but after the restart of nginx it won´t create the /var/pagespeed directory

    My Theme is a bit complecated, it can do things that you normalyonly can achieve with plugins. It also creates a new post type namely coupons. As the warning you wrote when installing WordPress with Redis (may have some issues with plugins) I guess that the problem is with the theme. When I create a normal post it won´t dissapear after that the Cron has done its work. Only the theme items / setting are all gone when purging the cache. couponsplugins.png
    BTW: all options are set to Off when I install the theme.

    I will load the demo data again to do some latest testings but I have some question for you eva2000.

    1)How to change redis server default database = 0 into another value
    2)How to run the cron manualy, because only after the cron the problem is of missing db entries starts.
     
    Last edited: Mar 27, 2019
  6. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    yes you'd need to create that manually

    linked and quoted in my previous post to PageSpeed System Integration for ngx_pagespeed's redis database number change
    which cron ?
     
  7. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    Just found out. Running the /root/tools/wp_updater and again after flushing the cache everything is gone.
     
  8. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    wp updater cron doesn't do anything other than update wp plugins and if there is an update, restart nginx. It shouldn't touch redis caching at all.
     
  9. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    Strange, because after running the updater all theme options are gone. The rest is kept in place. Nothing is missing only the theme options. All post, coupons, images, everything is there.

    Gona try option 22 - 1 or 3 to see if the same happens when the updater runs.
     
    Last edited: Mar 27, 2019
  10. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    Went for option 22 - 1 and installed the theme with the demo data. No futher optiomalization, activated ngx_pagespeed and refreshed the site several times. Ran the updater, got the email and checked the site again and no problem.

    Page size with redis was about 2MB and loading time 300ms, now the pagesize is about 650KB and the loading time 330ms. Even the Pagespeed and Y-slow score are a lot better than with Redis.

    Final Conclusion. Read and go for it, install the default & recommended WP cache. Option 2 realy has some issues. In my case when the updater ran.
    Code (Text):
    Default is to install KeyCDN WP Cache Enabler Plugin
    as it's more stable and reliable than WP Super Cache.
    Redis cache may have issues with caching due to long 6hr cache TTL
    You can select which caching method to use below:
    
    --------------------------------------------------------
            Wordpress Caching
    --------------------------------------------------------
    1). KeyCDN Cache Enabler (default & recommended)
    2). Redis Nginx Level Caching (may have issues with some wp plugins)
    3). Wordpress Super Cache
    --------------------------------------------------------
    Enter option [ 1 - 3 ] 1
    
     
  11. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    yup cache enabler method 1 is the default recommended caching method for a reason :D
     
  12. Kuro

    Kuro Member

    82
    12
    8
    Feb 8, 2018
    Ratings:
    +19
    Local Time:
    10:00 AM
    1.15.10
    10.3
    I think.... Plugins
    LOL

    upload_2019-3-27_22-43-35.png
     
  13. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    With Option 22-1 still the same problem. All theme data is gone.
    Before it looks like this:

    belgie.png

    Afterward like this:
    after.png

    This is driving me crazy.

    @eva2000 I need your help to debug this issue, with ISPconfig I did not have this problem.
     
    Last edited: Mar 29, 2019
  14. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    is it only that theme ? tried other themes to see if they also have problems ?
     
  15. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    try commenting out the wp updater cronjob and letting just wordpress native wp-cron run for a few days and see if the problem still happens to confirm if it is really wp updater cronjob script first.
     
  16. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    is data gone from database or is it just the html not rendering ? you can use chrome web browser's dev tools and network and source and console inspection to verify what is seen.
     
  17. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    All theme data is gone, when I look when I am the wp-admin and go to the theme options they are all missing.
    I did manually test the wp_updater and that did not give me any problem. I let the site running for 2 days without looking at it because I was busy testing to create a system image with dd if=/dev/vda1 | gzip -c > vda1.img.gz on a mounted disk in recovery mode to test if I was able to shrink it manually on my local PC with Gparted.

    So the server had a reboot.

    I can not test it with another theme because this theme is the theme I need for sites / servers worldwide. (Also I Australia!). My final target is to create my own type of CDN with DNS load balancer and a MariaDB cluster. To pay USD 200,00 for each domain on CloudFlare is too expensive.

    I think that the best thing that I can do is to destroy this Droplet (thanks anyway for the Referral link for Digital Ocean) and create a new one. Maybe I forgot some things to undo the setting while setting up Redis.
     
  18. eva2000

    eva2000 Administrator Staff Member

    45,432
    10,307
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,986
    Local Time:
    1:00 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    I mean data in the mysql database tables related to that theme/plugin's settings ? Is that missing ? If it's just on frontend, then could be ngx_pagspeed filter conflicts so need to disable some filters for your theme.
    Yeah you spin up a new droplet and centmin mod install side by side with messed up one and compare the settings too
     
  19. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    Glad I download it before and used #qemu-img convert vda1.img -O vmdk vda1.vmdk so I can still use it in VMware
     
  20. EckyBrazzz

    EckyBrazzz Active Member

    873
    183
    43
    Mar 28, 2018
    >>>>Click here<<<< i'm nearby......
    Ratings:
    +334
    Local Time:
    12:00 AM
    Latest
    Latest
    No, it´s backend. Inside the WP-Admin part, the data is missing. I have to reinstall the demo data to get it back. The demo posts they are still inside the database. Only the complete demo theme layout and setting are missing.