Wordpress ~ Speed Optimization

Wordpress ~ Speed Optimization

Apache

To enable apache module in Plesk, go to Tools & Settings / Apache Web Server Settings and check the module.

Testing the performance

It’s not enough to enable gzip compression in your server - the client also needs to ask for it in its requests via the Accept-Encoding: gzip header.

ab -n 1000 -c 1 -k -H “Accept-Encoding: gzip, deflate” https://www.hostingtipp.ch/ ab -n 1000 -c 5 -k -H “Accept-Encoding: gzip, deflate” https://www.hostingtipp.ch/ ab -n 1000 -c 10 -k -H “Accept-Encoding: gzip, deflate” https://www.hostingtipp.ch/

| Technology | Req | Req | Req | Notes | | | Per | Per | Per | | | | Sec | Sec | Sec | |

/1 /5 /10
Apache w/ mod_php & pagespeed & gzip 5.99 23.37 25.27 fastest Apache setup, but not enough secure
nginx w/ PHP-FPM 6.36 25.15 24.74
nginx as above + gzip compression 6.29 25.45 25.73
nginx as above + other tweaks 6.26 24.85 25.40 but GTmetrix improved 88/69% to 93/75% because of “Leverage browser caching”
nginx as above + workers & etc 6.23 - 23.68 small tweaks, but TTFB (434 ms) score from 51 to 74/100.
Switch to SSL - - - TTFB (1009 ms) score from 14/100.
Upgrade PHP 5.6.6 & Zend opCache 11.16 52.74 59.21 Woow! TTFB (769 ms) score from 14 to 38/100.
Object Cache: APCu + plugin 6.88 30.07 31.24 Avoid! Confirmed: APCu Object Cache Backend. TTFB 814 ms (32/100)
Object Cache: APCu + W3TC plugin 10.44 46.93 50.92 Still slower? About 10%. TTFB 780 ms (36/100)
Full Page Cache: W3TC Disk Enhanced 29.64 141.36 186.35
Full Page Cache: W3TC APCu 34.86 131.90 182.81
Full Page Cache: W3TC Memcache 32.75 129.57 191.27 TTFB 677 ms (47/100)
Full Page Cache: WP-FFPC APCu 36.98 136.88 185.57
Full Page Cache: WP-FFPC Memcache 36.19 140.00 190.55
Full Page Cache: WP-FFPC Memcached 36.87 138.74 193.19
Full Page Cache: nginx fastcgi_cache 49.50 140.95 192.44 Microcaching 5s: TTFB 696 ms (45/100)
Optimization: ngx_pagespeed 28.37 121.77 184.13 TTFB 375 ms (77/100)
Optimization: ngx_pagespeed w-memcached 30.06 120.46 187.57 The same, but easier - no need for dir permissions

On webpagetest.org, we have only First Byte Time (back-end processing) score of 51/100. Current value of 661 ms for First Byte Time must be lowered below 177 ms First Byte Time.

Optimizing NGINX TLS Time To First Byte (TTTFB)

How Time to First Byte Impacts Web Performance

Time to first byte (TTFB) had the most significant correlation: inversely correlated with search engine rankings. ie. its important for seo. no correlation with page load speed but sizable inverse correlation with TTFB. (position 1: 0.39 sec to position 8: 0.51). It’s useless for UX, but has extreme effect for SEO.

Stop worrying about Time To First Byte (TTFB) How Website Speed Actually Impacts Search Ranking - Moz


Load Testing Apache with AB (Apache Bench) Measuring your web app performance with Apache Bench

Wordpress Cache Plugins

Support » WP Super Cache vs W3 Total Cache wp-cache « Tags W3 Total Cache The Best WordPress Caching Plugins WP Super Cache vs W3 Total Cache Comparison WordPress Caching Plugin Test - W3TC vs SuperCache vs QuickCache

Checklist For Perfect WordPress-Nginx Setup WordPress Nginx Tutorials

Nginx « WordPress Codex

WP-FFPC Plugin: Varnish alternative for full-page caching

In my tests, WP-FFPC is around 10% faster than W3TC. But, I am still not sure if I should use it because it is only a page-cache, and W3TC has multiple other options enough to keep him installed.

WP-FFPC supports a lot of storage backends (both PHP Memcache and Memcached extensions, APCu), except Redis.

When WP-FFPC plugin and Nginx ngx_pagespeed module are paired together, they make a perfect couple with WP-FFPC taking care of caching and Nginx ngx_pagespeed taking care of optimising static css, js and image page elements replacing the more common but complicated W3 Total Cache plugin.

No caching plugin: Time to First Byte: 234 ms (399 ms First Byte Time)

WP-FFPC full page plugin with memcached via PHP: Time to First Byte: 60 ms (267 ms First Byte Time)

WP-FFPC full page plugin with memcached via nginx: Time to First Byte: 54 ms (267 ms First Byte Time)

W3TC full page plugin with memcached via PHP: Time to First Byte: 65 ms (199 ms First Byte Time)

While looking at the source code I concluded (hook: transition_post_status) that WP-FFPC invalidates cache for post/page on any change. So it is safe to increase cache expiration period from 300 seconds (5 min) to 12 hours (43200 sec)

WordPress Optimization/Caching

WP-FFPC Speed Test Based on above test results, we should be using Memcached via PHP option.

Best Wordpress Cache Plugin: WP-FFPC

W3 Total Cache (W3TC) Plugin: de-facto standard

Reason to install W3TC anyway? There is no better CDN management in WordPress than W3TC. Using FFPC for page cache and W3TC for CDN and object cache.

W3TC Settings

General Settings sub-section, General, check Toggle all caching types on or off at once. Disable features if you don’t have them (CDN, CloudFlare, etc).

Minify sub-section: There is an option called Minify mode. Select the Auto option. Also, under HTML & XML, check Enable in the HTML minify settings:. You can also check the other options, but make sure to test your site to see if it breaks.

In the Browser Cache sub-section, enable the following: Set expires header, Set cache control header, Set entity tag (eTag)

The Ideal W3 Total Cache Settings, with screenshots How to Setup WordPress Caching with W3 Total Cache (W3TC)

Best Settings to work with W3 Total Cache

Best W3 Total Cache Settings For Increasing Website Speed Caching Plugins for WordPress: Five Leading Solutions

Disable the comment signature of W3TC

Disable the W3 Total Cache Footer Comment

Tools To Test Speed

Really perfect writeup of current offerings of page speed test tools.

WebPagetest can show all the public test history, but Pingdom has a free monitoring.

FeedTheBot is the best tool to test bth the speed but also a compliance with Google’s recommendations. The same site contains beautiful SEO tool.

  • Google PageSpeed Insights

  • SiteSpeed.me is a great idea. It will check site availability and speed from different spots around the world.

  • WhichLoadsFaster will load two sites in parallel and compare their speed. Very interesting.

  • Show Slow collects performance metrics over time from YSlow, Page Speed Insights, WebPageTest and dynaTrace AJAX Edition rankings.

Website Speed Test by Stat My Web

Check HTTP headers and explain them with REDbot.

Page Speed Testing Tools

Waterfall charts explained

Beginner’s Guide to Waterfall Charts How to use a waterfall chart to diagnose your website’s performance pains

CDN: using Cloudflare with Wordpress

Using CloudFlare and WordPress

W3 Total Cache & CloudFlare Speed Up WordPress with PageSpeed or CloudFlare CDN

Top CDN Services to Make Your WordPress Site Blazingly Fast (and More Reliable) - WPMU DEV

Integrating CloudFlare With WordPress - Tuts+ Code Tutorial


muypotente.ch is using WordPress HTTPS plugin


Desktop tools for Web Debugging & Performance Testing: Fiddler


EWWW Image Optimizer


Disable stylesheets selectively

Lot of styles and scripts are used only on some specific pages.

How WordPress Plugins Affect Your Site’s Load Time

Prevent WordPress to compress JPEG images on upload

Wordpress compresses all JPEG images on upload. GIFs and PNGs are not compressed. Default compression value is to 90% of original size, but usually it only looks uglier and very little space saving.

To disable this feature, add the following snippet to your theme’s functions.php file:

add_filter('jpeg_quality', function($arg) { return 100; });
add_filter('wp_editor_set_quality', function($arg) { return 100; });

Remove Extra JS included for Emoji Support

Starting from version 4.2, WordPress supports Emoji’s by default. It means, an extra Javascript file gets added to your site’s header to support 4 bit unicode characters.

Please note: the emoji code added in 4.2 runs asynchronously. There is no additional load time added because of it.

Disable on frontend:

remove_action('wp_head', 'print_emoji_detection_script', 7 );
remove_action('wp_print_styles', 'print_emoji_styles' );

Disable on Admin pages:

remove_action('admin_print_scripts', 'print_emoji_detection_script' );
remove_action('admin_print_styles', 'print_emoji_styles' );

WordPress emoji performance is counter intuitive Disable WordPress Emojis Remove extra Javascript file added for Emoji Support in WordPress

Hide secondary RSS feed URLs from HTML

remove_action('wp_head', 'feed_links', 2 ); 
remove_action('wp_head', 'feed_links_extra', 3 );

How to hide secondary feed urls in WordPress?

Remove unneeded meta-tags

How to remove unnecessary meta tags and data from WordPress pages?

remove_action('wp_head', 'wp_generator' ) ;
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
  • wlwmanifest_link: tagging support for Windows Live Writer.
  • rsd_link: similar, but link to Really Simple Discovery service

Remove jQuery Migrate

Ignoring this suggestion.

jQuery Migrate is unneeded script, but it is too small to gain some special benefits of disabling it.

Stop WordPress Including jQuery Migrate File Disable jQuery Migrate Loading in WP Remove jquery-migrate.js from wordpress pages


Consider doing: Google CDN for jQuery and others. Don’t Dequeue WordPress' jQuery

Use public CDN libraries for common scripts

There a lot of articles how to replace default WordPress jQuery script with Google Library

We can also use a plugins: Use Google Libraries


Maybe?? - How to remove query string from WordPress URL? Optimize wordpress site by removing query strings from URL resources


Experts on fast Wordpress. Their configuration.

hgv/provisioning/roles/nginx/templates/etc/nginx at master · wpengine/hgv


Install Monit! Speed up WP admin with Redis and HHVM

Nice config:

Using Yii with Nginx and PHP-FPM | Wiki | Yii PHP Framework

  • SPDY

Nice: Diagnose admin-ajax.php Causing Slow Load Times in WP

Speed Up WordPress with these 5 Expert Tips


A Beginner’s Guide to Website Speed Optimization by Kinsta



StartSSL: Switch to HTTPS Now, For Free


HTTPS on Nginx: From Zero to A+ (Part 2) - Configuration, Ciphersuites, and Performance - Julian Simioni


Retrieving cache directly from nginx & memcached

HTTP response headers are not stored in memcached. This can be a problem

  • specially for browser caching (or not). I think that the Nginx Redis module has the same problem. I also noticed meta- in settings of WP-FFPC, but not sure how to use them or retrievemeta- them in nginx.

HTTP caching with Nginx and Memcached

One possible route is to use alternative modules for nginx, most notably ngx_http_enhanced_memcached_module or maybe even memc.

Some more info here


Caching in nginx (fastcgi_cache) explained

Sources:


date 01. Jan 0001 | modified 28. May 2021
filename: Wordpress - Speed Optimization