Caching Plugin W3 Total Cache (W3TC)

Caching Plugin W3 Total Cache (W3TC)

Fixing and configuring W3TC:

Frederick Townes Confirms W3 Total Cache is Not Abandoned in this article


This bug still exists: Bug: W3 TotalCache with HHVM on save-up.ch | Trello

In version 7.0.9 reference arguments were disallowed in call_user_func(). This is how to find them in the code:

cd /var/www/save-up.ch/web/

I needed to install old and obsolete package:

apt-get -y install php-memcache

Then change all the PHP7 problems:

# just find them
grep -Fnr 'ob_callback(&$buffer)' wp-content/plugins/w3-total-cache/*

# and change them
cd wp-content/plugins/w3-total-cache/
find . -regex '.*/\(PgCache\|NewRelic\|Cdn\|TotalCache\|Minify\|BrowserCache\)\.php' -exec sed -i 's;ob_callback(\&\$buffer);ob_callback(\$buffer);g' {} \;

Interesting plugins:

[Broken Link Checker](https://wordpress.org/plugins/broken-link-checker/)

[WP Engine GeoIP](https://github.com/wpengine/geoip)
[WP Engine Ecommerce Toolkit for WooCommerce](https://github.com/wpengine/wpe-wc-toolbox)

Final cache solution:

Page Cache:

  WP-FFPC - simple page cache - supports both memcached, memcache, APCu and soon Redis; has decent warm cache / precache functionality

Database Cache:

  I guess MySQL is doing a decent job on its own.

Object Cache:

  Reduced number of DB queries incredibly.
  [APCu Object Cache Backend](https://wordpress.org/plugins/apcu/)

Fixing APCu restarts

This is not, as my APCu is compiled with MMAP support

Based on this comment: https://github.com/krakjoe/apcu/issues/91#issuecomment-138247668

When APCu is compiled with mmap support (Memory Mapping), it will use only one memory segment, unlike when APCu is built with SHM (SysV Shared Memory) support that uses multiple memory segments. MMAP does not have a maximum limit like SHM does in /proc/sys/kernel/shmmax. In general MMAP support is recommeded because it will reclaim the memory faster when the webserver is restarted and all in all reduces memory allocation impact at startup.

PHP: Runtime Configuration - Manual

sysctl -a | grep shm cat /proc/sys/kernel/shmall | numfmt –to=si cat /proc/sys/kernel/shmmax | numfmt –to=si

Setting SHMALL Parameter Setting SHMMAX Memory

echo 2147483648 > /proc/sys/kernel/shmmax

Decide on value:

numfmt 10Gi --from=iec-i >/proc/sys/kernel/shmall
numfmt 10Gi --from=iec-i >/proc/sys/kernel/shmmax

But I realized APCu is NOT using shm by typing: ipcs -m

https://gist.github.com/jodell/1285137


WordPress › Support » Admin area resets APCu cache http://www.skooterblog.com/en/2016/02/23/w3-total-cache-com-php-7-e-apcu/

WP-FFPC

Cache invalidation method MUST NOT be: flush cache! as then it clears cache everytime you enter admin.


You must test from Chrome in Brussels, as stream prioritization is properly set there. Or you could test in Firefox.


Problem with W3TC:

Fragmentation of cache! But it seems that it stems from object or database cache, not page cache.

My final decision:

1. Use the fastest and most compatible one (W3TC?)
2. Database cache: do not use at all
3. Object cache. Use the one that simply works.

   Update: Disabling object caching and db caching help reducing the fragmentation. Us'ng redis or memcached for object caching.

   - Crazy fragmentation. W3TC Object Cache seems to slows down my site? 
     Default lifetime of cache objects: 86400 (1 day)
     Update: Disabling object caching and db caching help reducing the fragmentation. Using redis or memcached for object caching
     [php - How to prevent APC cache fragmentation - Stack Overflow](http://stackoverflow.com/questions/15578157/how-to-prevent-apc-cache-fragmentation)

I was thinking a lot about Redis cache. Still not decided to use it. Redis Object Cache Redis Page Cache Redis Page Cache for WordPress

W3TC conflicting with WP Redis as object cache? WordPress › Support » W3TC conflicting with WP Redis

Currently we have stopped using PageSpeed and W3TC internally for all our sites.


Redis GUI

Every one of GUI’s were shitty or overly complicated, so I will simply use:

redis-cli info memory | grep -e human -e frag

Great article on how to Monitor Redis.

This is very interesting tool:

Sources:


By the way W3TC is still recommended for object-cache which nginx_pagespeed doesn’t handle. Speeding up backend is equally important.


nginx Configure for Wordpress: WordPress-Nginx + W3 Total Cache


PHP extension for Redis

phpredis/phpredis: A PHP extension for Redis

cachewerk/relay: The next-generation caching layer for PHP powered by Redis. is is a drop-in replacement for PhpRedis as well as a shared in-memory cache like APCu but faster as it all retrieved keys are also held in PHP’s memory, which is shared across all FPM workers.


Scripting - WebPagetest Documentation

logData 0 // authenticate navigate https://www.save-up.at/wp-login.php?login_key=etk setValue id=user_login etaktiker setValue id=user_pass 42q!fKvJ#k#NMeKVLEhLvxsk clickAndWait id=wp-submit

logData 1 // start measuring navigate https://www.save-up.at/wp-admin/edit.php?post_type=voucher

navigate https://www.save-up.at/wp-admin/post-new.php?post_type=shop

Warsaw:

Pg: none
Db: none
Oj: none                        400 ms (list vouchers), 400 ms (new shop)

Pg: W3TC APCu
Db: none (Query Monitor)
Oj: W3TC APCu                   410 ms (list vouchers), ? ms (new shop)

Pg: W3TC APCu
Db: none (Query Monitor)
Oj: none                        410 ms (about the same, checked twice)

Pg: W3TC APCu
Db: none (Query Monitor)
Oj: APCu Object Cache           569 ms (slower?)

Pg: W3TC APCu
Db: none (Query Monitor)
Oj: W3TC APCu                   375 ms (list vouchers), 400 ms (new shop)

Pg: none
Db: none
Oj: W3TC APCu                   380 ms (list vouchers), 380 ms (new shop)

Pg: W3TC APCu
Db: W3TC APCu
Oj: W3TC APCu                   900/420 ms (list vouchers), 420/900 ms (new shop) - slower a lot


Pg: none
Db: none
Oj: Redis Object Cache          400 ms (list vouchers), 420 ms (new shop)

Conclusions:

1. Page cache really doesn't influence backend speed at all.
2. Database cache significally slows down backend queries, but not in a consistent matter (every couple of requests, slows by double).
   Anyway, I need this to be unused as I want to use Query Monitor plugin that also hooks to db.php cache.
3. Object cache can sometimes improve speed, a little (~8%).
   But it surely and always reduce number of DB queries. So I will use it.

Explanation:

As Khromov explained: If your DB server performance is bad, persistent Object Cache may help. But when it’s on the same machine as your web server, they share the same resources so this doesn’t apply, hence installing persistent object cache on a single-server environment is largely futile and may actually decrease performance.

https://www.digitalocean.com/community/tutorials/how-to-configure-redis-caching-to-speed-up-wordpress-on-ubuntu-14-04?comment=34861

Why Not Persistent Object Caching?

But for many cases in-memory persistent object caching can actually hurt performance.

Plugins these days go crazy with options and transients and metadata. A simple “retrieve 10 latest posts” will result in 10 round trips to Redis for posts, another 10 for postmeta, another 10 or so for terms in addition to one MySQL query to retrieve the posh IDs. All of this versus just four MySQL queries without persistent object caching.

What’s worse is that if the object cache backend doesn’t have the requested items (which could have been evicted to make room for others), it could result in an additional 30 queries to MySQL. This is just one example.

We’re not saying persistent object caching is bad. It’s really good in targeted cases, where it’s being used on purpose, and not just slapped on. We do deploy persistent object caching for some customers that require it, but we can’t simply deploy it across the board and expect everyone’s performance to magically improve.

Redis-Backed Page Caching for WordPress


OpCode Cashe was too small

echo "opcache.memory_consumption=256" >>/etc/php/7.0/fpm/conf.d/10-opcache.ini
echo "opcache.max_accelerated_files=6000" >>/etc/php/7.0/fpm/conf.d/10-opcache.ini
service php7.0-fpm restart

https://www.scalingphpbook.com/blog/2014/02/14/best-zend-opcache-settings.html https://tideways.io/profiler/blog/fine-tune-your-opcache-configuration-to-avoid-caching-suprises

php70u/opcache.ini at master · iuscommunity-pkg/php70u PHP 7 Opcache adds Huge Pages support for extra performance | ck says…


date 23. Aug 2016 | modified 10. Jun 2024
filename: Plugins » Cache » P » W3TC Fixing