Simply Fast WordPress [4] Techniques to Speed Up WordPress 540% with CentOS 7 (Cont)

This is a series of articles explaining how to speed up WordPress, the use of which is growing rapidly for CMS-based business sites and media sites. In part 4, I will continue to explain how to speed up WordPress by 540% just by using the standard CentOS environment. --Kengyu Nakamura, Prime Strategy Co., Ltd.

In the previous article , we installed the PHP accelerator OPCache, edited parameters for MariaDB, and installed a translation accelerator to get WordPress 480% faster.

In this article we will continue to push that to 540%.

WordPress Japanese version
WordPress Japanese version

Reduce transmission time with gzip compression

First, we will use Apache settings to shorten transmission time.

Basically, any HTML or files that are sent to the browser from the web server will be compressed with gzip to shorten the time it takes. It will work on WordPress HTML and XML as well as CSS and JavaScript files.

gzip can compress a text file to 1/4th its original size. With it you will not only increase speed but also save on bandwidth.

We will also configure settings to strengthen the browser cache and control the HTTP response header Expire field and Cache-Control field. For our purposes we will set the MIME Type text/html to 10 seconds and all others to 600 seconds.

Add the following code to the end of "/etc/httpd/conf/httpd.conf":

# gzip setting
AddOutputFilterByType DEFLATE text/html text/plain text/css
AddOutputFilterByType DEFLATE text/javascript application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html# expire setting
ExpiresActive On
ExpiresDefault "access plus 600 seconds"
ExpiresByType text/html "access plus 10 seconds"

Restart Apache for the changes to take effect.

[root@ip plugins]# systemctl restart httpd

Load the front page in your browser, and you can see with Firebug that the HTML source files, CSS, and JavaScript have been reduced to 1/4th their original size. And if you look in the header tab you should see "gzip" under Content-Encoding. Page load time has only decreased a little; in my environment it was 35ms.

Checking the header with Firebug to see gzip installed
Checking the header with Firebug to see gzip installed

However, if you refresh the front page by clicking links in your site rather than using F5, you will see that the browser cache is working according to our Expire settings.

More optimization with Tuned settings

Let's configure Tuned and get even more speed.

Tuned is a daemon that optimizes system settings based on the status of the OS. There are many profiles to choose from, so it is important to choose the most appropriate one to boost your OS performance.

Using the "tuned-adm list" command, you can see the available profiles and the currently assigned profile.

[root@ip plugins]# tuned-adm list
Available profiles:
- balanced
- desktop
- latency-performance
- network-latency
- network-throughput
- powersave
- throughput-performance
- virtual-guest
- virtual-host
Current active profile: virtual-guest

As you can see above, the profile is set to virtual-guest. We want to change this to throughput-performance, which increases disc and network I/O.

[root@ip plugins]# tuned-adm profile throughput-performance

In my environment, page load time was 34ms and requests per second was 58.47, several percent better performance.

Tuning contents Page load time Requests per second
Default environment 176ms 11.24
APC 70ms (251%) 29.20
OPcache+APCu 66ms (266%) 30.51
gzip 35ms (502%)
Tuned settings 34ms (517%) 58.47