Apache/WordPress performance

Google has added a parameter to their ranking algorithm that corresponds to how well your site performs. They created a tool called Page Speed Insights (https://developers.google.com/speed/pagespeed/insights/) that checks for a number of things: Initial load, time to first painting, time to full painting, time to interactive, etc.

It provides quite a lot of help for issues it discovers.

Things that it found with mine:

  1. Images were using legacy file types and were larger than if they were using webp. They suggested a WordPress plugin to convert existing images and serve the webp images in place of the current images. The plugin modifies the .htaccess file so that any requests are redirected to the smaller images.

    The plugin I used is called: WebP Converter for Media. Because of my proxy arragement, I had to do some additional manual configuration to get it to work. As my situation is unique, I won’t go into detail.

  2. Responses weren’t compressed and static files didn’t have a cache policy. This was an apache change that required loading a couple of modules: deflate, filter, cache and disk_cache.

Edit the httpd.conf file and add:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript

between the <Directory> tags

After the closing Directory tag add:

CacheEnable disk /

CacheRoot “/var/cache/apache2/”

CacheDirLevels 1

CacheDirLength 2

CacheDefaultExpire 3600

CacheDisable /wp-admin


Add the following to server-default.conf:

<IfModule mod_expires.c>

    ExpiresActive On

    ExpiresDefault “access plus 7 days”


<FilesMatch “\.(ico|html|pdf|jpg|jpeg|gif|png|webp|js|css)$”>

    Header set Cache-Control “max-age=604800, public”



To add the LoadModule lines to the config files, run the following commands:

a2enmod -l (list the current modules)

Look for filter, deflate, cache and cache_disk in the list.

Type the following, omitting any that are in the list above:

a2enmod filter

a2enmod deflate

a2enmod cache

a2enmod cache_disk

a2enmod headers

Then restart the daemon

systemctl restart httpd


It should display no errors.

After implementing these changes, I re-ran page insights and there was a significant score improvement. There is another metric called GTmetrix (https://gtmetrix.com/) that does a simliar job.

Leave a Reply

Your email address will not be published. Required fields are marked *