Overview

Do you want to speed up your WordPress site? Fast loading pages improve user experience, increase your pageviews, and help with your WordPress SEO. In this article, we will share the most useful WordPress speed optimization tips to boost WordPress performance and speed up your website.

Any website needs optimization done and if you aren’t too tech-savvy, it can be quite a daunting task.

Optimizing your website is no longer an option. With search engines placing so much importance on the speed of web pages, it is vital to your website’s success to have fast loading web pages.

A lot of people wrongly assume that you need to be an expert to optimize a WordPress website. Nothing could be further from the truth. 99% of optimizing your website correctly is following good practices and taking advantage of caching and content delivery networks.

The topic of WordPress speed and optimization seems to come off as quite a “info-overload” if you are just starting to look into how you can make these improvements. This guide should be able to get the basics done for in only a few minutes.

 

Check Your Pagespeed & Yslow Results

First thing to do is to check what your site GTmetrics scores are, look at the results and how it compares to other websites on average. If you would like to know more about the individual results of your website, I recommend reading this blog post from Kinsta – A Deep Dive Into the GTmetrix Speed Test Tool

Our looks like this –

gtmetrix

Modify the .htaccess File

Open your .htaccess file and add the below at the top of the file, if you don’t know where the .htaccess file, it should be located in the web root directory of your website – most commonly “public_html” folder.

#######################
# CORE #
#######################

Options -Indexes
Options -MultiViews
Options +FollowSymlinks
AddDefaultCharset UTF-8
ServerSignature Off
Header unset ETag
FileETag none

#######################
# EXTRA SECURITY HEADERS #
#######################

<IfModule mod_headers.c>
        Header set Cache-Control "max-age=2592000, public"
        Header set Strict-Transport-Security "max-age=10886400; includeSubDomains; preload"
	Header set X-XSS-Protection "1; mode=block"
	Header always append X-Frame-Options SAMEORIGIN
	Header set X-Content-Type-Options nosniff
        Header set Connection keep-alive
</IfModule>

<files wp-config.php>
order allow,deny
deny from all
</files>

# Block the include-only files.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
#######################
# ALLOW FONTS #
#######################

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

#######################
# CACHE CONTROL #
#######################
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>

#######################
# EXPIRES CACHING #
#######################

<IfModule mod_expires.c>
  ExpiresActive on
# whitelist expires rules
  ExpiresDefault "access plus 1 month"
# cache.appcache
  ExpiresByType text/cache-manifest "access plus 0 seconds"
# Your document html
  ExpiresByType text/html "access plus 0 seconds"
# Data
  ExpiresByType text/xml "access plus 0 seconds"
  ExpiresByType application/xml "access plus 0 seconds"
  ExpiresByType application/json "access plus 0 seconds"
# Feed
  ExpiresByType application/rss+xml "access plus 1 hour"
  ExpiresByType application/atom+xml "access plus 1 hour"
# Favicon
  ExpiresByType image/x-icon "access plus 1 week"
  ExpiresByType image/ico "now plus 1 month"
  ExpiresByType image/icon "now plus 1 month"
  ExpiresByType text/ico "now plus 1 month"
  ExpiresByType application/ico "now plus 1 month"
# Media: images, video, audio
  ExpiresByType image/bmp "now plus 1 month"
  ExpiresByType image/gif "access plus 1 month"
  ExpiresByType image/vnd.microsoft.icon "now plus 1 month"
  ExpiresByType image/png "access plus 1 month"
  ExpiresByType image/jpg "access plus 1 month"
  ExpiresByType image/tiff "now plus 1 month"
  ExpiresByType image/jp2 "now plus 1 month"
  ExpiresByType image/pipeg "now plus 1 month"
  ExpiresByType image/jpeg "access plus 1 month"
  ExpiresByType video/ogg "access plus 1 month"
  ExpiresByType audio/ogg "access plus 1 month"
  ExpiresByType video/mp4 "access plus 1 month"
  ExpiresByType video/webm "access plus 1 month"
# HTC files (css3pie)
  ExpiresByType text/x-component "access plus 1 month"
# Webfonts
  ExpiresByType application/x-font-ttf "access plus 1 month"
  ExpiresByType font/truetype "access plus 1 month"
  ExpiresByType font/opentype "access plus 1 month"
  ExpiresByType application/x-font-woff "access plus 1 month"
  ExpiresByType image/svg+xml "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
# CSS and JavaScript
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
  ExpiresByType application/x-javascript "access 1 year"
  ExpiresByType text/x-javascript "access 1 year"
</IfModule>

#######################
# GZIP COMPRESSION #
#######################

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
<IfModule mod_deflate.c>
   AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE image/svg+xml svg svgz
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-woff
    AddOutputFilterByType DEFLATE application/x-font-woff2
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/eot
    AddOutputFilterByType DEFLATE font/woff
    AddOutputFilterByType DEFLATE font/woff2
    AddOutputFilterByType DEFLATE font/opentype

 # For Olders Browsers Which Can't Handle Compression
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>

 

Recommended Plugin

We aren’t fans of having loads of plugins to accomplish individual tasks, but we would definitely recommend Swift Performance – the free and paid version are available, so continue with the free version and see how it works for you so for this exercise, go ahead and download Swift Performance Lite.

 

Summary

This only should cover the basics but have a big enough impact on your website, there are many thing that contribute to website speed such as optimized images, CDN’s and even hosting, so do your  homework and make the right choices.