How to Speed Up WordPress Site (Complete Guide)

WordPress is the most popular blogging platform in the world. In addition to the popularity of WordPress as a blogging platform, it is also used by a variety of other websites for a myriad of different purposes.

From small businesses to large media sites, WordPress is a platform that offers a lot of potential for a wide range of different websites.

The reason behind WordPress' growing popularity is what makes it unique: it is extremely easy to use, highly versatile, well supported by the community and yet very powerful.

Currently, it powers over 43% of all websites on the internet, according to a study by W3Techs. Consequently, it is a platform on which millions of people publish blogs, websites, forums, and more.

Despite this, WordPress sites used to run slow a few years back because of a performance bottleneck in the system. Without proper optimization, WordPress can become slow. Poorly performing, slow and clunky WordPress sites will drive your users away.

Increasing the speed of a WordPress site will increase user traffic and smooth the user journey. We will discuss why speed of a website is so important and how to enhance the optimization of the WordPress site.

Table of Contents

  1. Why is site speed important?
  2. Various methods to achieve a faster WordPress site

Why is site speed important?

Speed is the measurement of how fast the content loads on your website. There are many reasons out there that should raise an alarm. These are some of the most important reasons:

  1. Influence SEO with speed of the website: The search engines like Google have announced page load time will be a ranking factor in mobile searches. To rank and locate your website #1 in the SERP results, improve the page loading speed .
  2. Less Conversion Rate: A website must load within seconds to keep users engaged. According to Neil Patel, a 1-second delay in response time can cause a 7% decrease in conversion rates. This means improving the speed of a website will ensure better conversion rates.
  3. Increase in Bounce Rate: Kissmetrics statistics show that sites that take longer than 2 seconds to load page, decrease customer satisfaction by 16% and almost 40% of users abandon the site after that.
  4. Poor User Experience: Slow-loading websites will cause your customers to leave your site and look for your competitors, which will lead to major revenue losses. Your website should be fast enough to access for your customers to have a satisfactory experience.

The above factors are the major ones you should consider when building a website. You should aim to make the website run smoothly and quickly.

Various methods to achieve a faster WordPress site

Knowing how to optimize your WordPress site is the key to being successful. Here are 10 easy ways to improve the WordPress site.

  1. Optimize Image Size
  2. Choose a fast and responsive WordPress theme
  3. Use a CDN
  4. Enable Caching
  5. Minify CSS, HTML and JS files
  6. Choose a better web hosting provider
  7. Find performance bottlenecks and slow plugins with Atatus
  8. Optimize WordPress database
  9. Enhance background process
  10. Enable Gzip compression

#1 Optimize Image Size

Images are a crucial aspect of any website since they are the primary way in which visitors interact with your site. As per research, 65% of people are visual learners and 80% of users remember what they see and 20% of users recognise what they read.

Image Optimization

The right image format can reduce the bandwidth used to post images by around 30%. Images are primarily posted in the following formats:

  • JPEG - perfect choice for print and web content.
  • PNG - has a transparent background, more versatile and good for web graphics.
  • GIF - good choice when your graphic uses a relatively low number of colors.

Lighten your web pages, improve site's speed, and reduce the data usage of your users by optimizing the images.

Tips to optimize images to increase the speed:

  1. Compressing images reduces 40% of bandwidth.
  2. Use vector images instead of a raster image, since they decrease the page load time without reducing the image quality.
  3. Pick out the right image file format.
  4. Store images within the user browser cache or a proxy server for fast access.
  5. Host a CDN to store the images so that your users will get the images delivered to their screen from the nearest server to them which eventually will increase the page load response time.
  6. Last but not least by using a WordPress plugin. To streamline the above few steps you can easily use a WordPress plugin and optimize your image size.

WordPress plugin would be a great time-saver for us. You can streamline your image optimization processes with a few of the top WordPress plugins listed below.

i.) Smush

ii.) Optimus

iii.) Imsanity

iv.) Imagify

v.) EWWW Image Optimizer

#2 Choose a fast and responsive WordPress theme

It will be overwhelming while choosing the right theme for our website since there are thousands of free, open-source and paid options out in the wild. There are over 11,000 WordPress themes available.

What is a WordPress theme?

A WordPress theme is an assemblage of files that act together to create a graphical design of your website. A theme includes template files, stylesheets, images, and possibly JavaScript files. These are called template files.

Image Source: WordPress Themes

You can modify the theme as you want and display the content as you wish. There are 2 different themes available in WordPress.

a.) Free - It is basically free and has a limited set of features. Using a free theme should always be preceded by the reminder that "Nothing is free".

WordPress themes can be of varying quality. Some are really impressive, whereas others could lack features and be out of date. This can adversely affect the website's performance and SEO.

Examples of excellent free themes are:

  • Astra Free
  • OceanWP
  • Storefront
  • Neve
  • GeneratePress
  • Sydney

b.) Premium - These themes are developed professionally by small to large-scale companies. They include regular updates, advanced features, and functionality. The cost is usually between $50 and $100 for a single site license.

Some of the best premium themes are:

  • Avada
  • Monstroid2
  • BeTheme
  • Sydney pro

Choosing one among them will probably be a tedious task. Here are a few factors with which you can ensure whether or not the selected WordPress theme is fast enough. Improve site speed by opting the perfect WP theme for your website.

Tips to select the most suitable WordPress theme:

  1. Choose an accessible and responsive theme.
  2. It should be lightweight, bloat-free and fast.
  3. Codes used should be secure, valid and frequently updated.
  4. It should have proper support and documentation.
  5. It should be SEO optimized and AMP (Accelerated Mobile Pages) friendly
  6. It should be compatible with WordPress Multilingual Plugin.
  7. You should be able to customize the features in the theme.
  8. It should fully support page builders and other plugins.
  9. It must be licensed under GPLv2 or GPLv3.
  10. The theme should not depend on any other plugins.
  11. When you purchase a premium theme, the price should be minimal, and you shouldn't be restricted from accessing the theme.

#3 Use a CDN

The term "Content Delivery Network" (CDN) is becoming increasingly popular amongst technology companies. The reason for this is that CDN gives the end-user the option to load web content faster than what would be possible using traditional web hosting.

It allows the end user to access a website or a web application from any location, regardless of the geographical location of the server that hosts the website or web application.

The key to understanding the power of a CDN is understanding how it makes web servers more efficient by reducing latency (delay) in the delivery of content.

How does a CDN work?

CDN is a group of caches that are dispersed in many parts of the globe that functions as local servers of the web content.

CDN Workflow

The CDN's primary function is to distribute content between the different Points of Presence (PoPs) to improve the speed at which your website appears to your visitors. The more data centres in the same geographic region, the faster content is delivered to your site.

For example, you have users in Singapore, London, USA, India and so on. A user in London is trying to access your web application. The user sends a request to the web server to retrieve all the page's components. Imagine your origin server is in India which has the web page's entire content such as images, JS and CSS files, HTML and other dynamic content. Now, you have to deliver it to the user's browser which is in London and this distance will cause delays and performance bottlenecks.

If you have CDN, we store the content in the local PoPs that are nearer to the user's location. It caches the files and delivers the static content to the user immediately. If the CDN doesn't contain the files that the user has requested, it will load it from the origin server.

Significance of using a CDN:

  1. Enhances site speed, performance, end-user experience by handling the peak time load.
  2. Reduces packet loss and network latency.
  3. Improves site content availability.
  4. Decelerates server load.
  5. Increases the number of synchronous users.
  6. Reduces bandwidth costs.
  7. CDN protects you from denial-of-service (DoS) and distributed denial-of-service (DDoS) attacks.

Some of the popular CDN providers:

i.) Cloudflare

ii.) KeyCDN

iii.) CDN77

iv.) StackPath

v.) Amazon CloudFront

vi.) Akamai

#4 Enable caching

Caching is a powerful way to improve site speed, but it can be confusing to know which methods are best for your website. It is one of the most prominent and indulgent ways to speed up WordPress.

What is Caching?

Caching is the process of storing copies of web pages in temporary storage spaces called caches. When a user requests the same webpage again from the browser, it doesn't have to go to the server, instead, it loads it from the cache. Caching allows users to browse pages more quickly, even when bandwidth is scarce.

When your site is cached, it saves time for your users. However, some web pages are more time-consuming to download than others. If your site is slow, then you can improve your site performance by using caching to improve your site's page load time.

There are two different approaches to caching:

a.) Caching at the server level

It is one of the simplest approaches for the user. The WordPress hosting provider itself handles this type of approach and there are 4 types of cache available, which are all automatically done at the server level.

  • Page cache
  • ByteCode cache
  • Object cache
  • Opcode cache
  • CDN cache

b.) Caching with a plugin

The easiest way to do this is to use a caching plugin, which automatically makes your site load faster by storing static content on your server instead of constantly requesting it.

Based on the suggestions from google trends below are the most recommended options:

  • WP Rocket
  • Swift Performance
  • W3 Total Cache
  • WP Super Cache

With the help of these plugins, you can enhance the speed of your website by instructing them to preload the files, image assets and store them into the user's disk or RAM depending on the configuration.

You can also check out the other options available on the most frequently used WordPress Caching plugins.

Benefits of using caching

  1. The cached information serves the consequent requests that help to reduce the overhead of recreating the same information again and again.
  2. It reduces the load on the webserver and database.
  3. Decreases network cost by caching the content at various points in the network path between the consumer and the origin.
  4. You can retrieve the content faster by avoiding the entire network round trip which helps to deliver faster content to your users.
  5. Caching technique delivers the content to the end-users even when it is not available on the origin server.

#5 Minify CSS, HTML and JS files

Minification reduces your site's size from the original download by removing the unnecessary or redundant bytes from the files it downloads, which is a great optimization for users on a slow connection.

Minification can be very useful for improving load times, reducing page size, increasing security, and designing for future-proofing.

It is one of the best ways to enhance the performance of your site, and if you do it right, it will not affect the code's functionality.

Examples of what is removed during the minification:

  • Comments
  • Line breaks
  • Whitespace characters
  • Block delimiters

Unminified CSS version:

body {
    padding-left: 11em;
    font-family: Georgia, "Times New Roman", Times, serif;
    color: purple;
    background-color: #d8da3d;
}

ul.navbar {
    list-style-type: none;
    padding: 0;
    margin: 0;
    position: absolute;
    top: 2em;
    left: 1em;
    width: 9em;
}

ul.navbar li {
    background: white;
    margin: 0.5em 0;
    padding: 0.3em;
}

ul.navbar a {
    text-decoration: none;
}

a:link {
    color: blue;
}

a:visited {
    color: purple;
}

Minified CSS version:

body {padding-left: 11em;font-family: Georgia, "Times New Roman", Times, serif;color: purple;background-color: #d8da3d }ul.navbar {list-style-type: none;padding: 0;margin: 0;position: absolute;top: 2em;left: 1em;width: 9em;}ul.navbar li {background: white;margin: 0.5em 0;padding: 0.3em;}ul.navbar a {text-decoration: none;}a:link {color: blue;}a:visited {color: purple;}

Atatus offers a tool to minify the CSS named CSS Minifier which is completely free of use. You can upload your CSS file or copy and paste the CSS code in the text area then click on minify. You will get the minified CSS code in the output box.

CSS Minifier

There are so many minification tools available out there with which you can easily minify your CSS, HTML and JS files.

#6 Choose a better web hosting provider

Hosting is critical to the success of your website; it can make or break your online presence. The right host can give you the resources you need to create great content while also ensuring that your site has the resources to function perfectly.

What is Wordpress Hosting?

It is specifically designed for WordPress websites which provides better performance, speed and security for all your users.

While it may seem impossible to choose a host that fits every need, the truth is that there are a lot of things to consider when picking a hosting provider.

Not only must a host be reliable, but it needs to be compatible with the software you use, be available 24/7, and have a customer support team that is well-versed in their field.

There are 5 different types of WordPress hosting. Get a basic understanding of what the different types of hosting and plans can bring to the table.

Overview of WordPress hosting types

Types of Hosting Best for Speed Stability Scalability Flexibility Examples
Shared Hosting Beginners Low Medium Low Low SiteGround
VPS Hosting Websites with medium traffic Medium to high Medium to high Medium High InMotion Hosting
Dedicated Server Hosting High-traffic websites with lot of resources High High High High LiquidWeb
Managed Wordpress Hosting Small to medium websites High High Medium to high Medium Pagely
Cloud Hosting Anyone depending upon the plan High High High High WPEngine

How to choose the best hosting provider?

  1. Know your website's requirements and choose a hosting provider with the needed features and verify the primary features.
  2. Check for quality of support.
  3. Determine the budget by considering your needs.
  4. Verify if they offer staging environments.
  5. Check for server reliability and uptime guarantees.

Below is a couple of the best WordPress hosting providers that might be useful for you.

i.) SiteGround

SiteGround is a splendid choice as a hosting provider for a WordPress site. They offer a wide range of hosting options, with a 99.9% uptime guarantee.

Besides these core hosting services, SiteGround offers several unique services that make their hosting a perfect fit for a WordPress site.

SiteGround

The hosting company's focus on WordPress and security makes it a top choice for hosting WordPress. It is especially significant if you use custom plugins and themes.

Reasons to use SiteGround:

a.) It offers a 30-day money-back guarantee, which makes it a good choice for most people.

b.) They provide reliable, fast, uptime and secure hosting with exceptional customer service and excellent features.

c.) It provides hosting solutions from shared, VPS, dedicated server to cloud and wordpress hosting.

d.) It ultimately provides free daily backups and restores on all plans.

e.) Cloudflare is included for free and also provides a staging tool.

f.) Free website builder,  WordPress migrations and SSL certificates.

g.) Unlimited free email accounts.

Pricing:

  • StartUp - $3.99/mo.
  • GrowBig - $6.69/mo.
  • GoGeek - $10.69/mo.

You can easily compare the hosting plans and the features they offer under each plan here.

ii.) Bluehost

Every small business owner needs a website. But choosing the ideal hosting service can be overwhelming. That's where Bluehost comes in. It is a perfect option for anyone building a new website from scratch.

Bluehost

They offer generous packages with tons of features, including unlimited disk space, monthly website backups, and 24/7 support.

Reasons to use Bluehost:

a.) Unlimited traffic.

b.) Free domain name for a year.

c.) Free WordPress migration.

d.) 1-click WordPress installation.

e.) Unlimited Parked Domains and subdomains

f.) Supports shared, VPN, dedicated, cloud, WooCommerce and WordPress hosting.

g.) Endorsed by many leading organizations like Neil Patel, Pat Flynn and so on.

Pricing:

Choose the best pricing plan that fits your need with the below tabular column.

Shared Hosting Pricing Plan

Basic Plus Choice Plus Pro
$2.65/mo* $4.95/mo* $4.95/mo* $11.95/mo*

Dedicated server hosting

Standard Enhanced Premium
$79.99/mo* $99.99/mo* $119.99/mo*

VPS hosting

Standard Enhanced Ultimate
$19.99/mo* $29.99/mo* $59.99/mo*

iii.) Hostinger

Hostinger stands out from the rest with its emphasis on simple, affordable hosting combined with an excellent support team.

It is a reliable and cheap web hosting service created back in 2006, and it has been around for a long time. However, it still holds an excellent reputation in the web hosting industry.

Hostinger

It is also a part of the ICANN-accredited registrar’s community.  LightSpeed is an adaptive caching system that speeds up the performance of your blog while offering a good level of compatibility with your plugins.

Reasons to use Bluehost:

a.) The average response time of WordPress sites hosted with them was 143ms which indicates that the sites are more reliable and fast.

b.) It is simple, fast and scalable.

c.) Easy navigation and customization of the website.

d.) It offers a free domain, website migration and website builder.

e.) It uses SSD storage for hosting.

Pricing:

  • Single web hosting : Starts at ₹79/month and it is more suitable for beginners.
  • Premium web hosting : Starts from ₹139/month and it is perfect for personal websites.
  • Business web hosting : Starts from ₹279/month and suits small and medium businesses

Here is a list of additional hosting companies that may meet your needs:

  • WP Engine - Best for managed WordPress hosting.
  • Cloudways - Best suited for customization.
  • Dreamhost - Perfect choice if you are not interested in long contracts.
  • Nexcess - It is a budget-friendly hosting provider.
  • A2 Hosting -  It will be best if you are migrating your site from another hosting provider.

Choose the best hosting provider that fits your needs and build a better website that provides an extra-ordinary end-user experience for your users.

#7 Find performance bottlenecks and slow plugins

When a website takes too long to load, it can be frustrating, but it can also indicate a problem. The best thing to do first is to get some basic information about the site before you try to fix it.

Several tools are available to speed up your WordPress site that can help in this regard, including Atatus, New Relic, Pingdom, and many others.

Atatus can assist you in finding and remediating the performance bottlenecks in your WordPress application based on detailed actionable insights.

With many unique features, you can easily figure out what is causing difficulties with your WordPress website.

See which transactions are taking the longest to complete, HTTP failure rates with the exact status codes, exceptions with the exact line of code where errors occur, slow database queries, slowest external requests with response times and much more.

APM Dashboard

This blog outlines how Atatus can help you identify WordPress performance bottlenecks in your site: How to find WordPress performance bottlenecks with Atatus

#8 Optimize WordPress DB

Since databases store all your vital information, you must know how to optimize your WordPress database. By lifting your database, you'll be able to keep your website running efficiently rather than hogging your server resources.

WordPress stores data like posts, pages, comments and custom post types such as links, form entries and so on from your website in a database, and the more content you decide to store, the more it will bog down your site.

With a database plugin or a database management tool, you can eliminate unwanted data, locate and fix errors and inconsistencies to increase your website's efficiency.

By enhancing the data and the SQL queries that you use on your site you can improve the site load time, Time to First Byte (TTFB), and overall end-user experience.

Listed below are a few ideas for optimizing your WordPress database to speed up your WordPress site:

1.) Optimize tables

With the command optimize table, you can easily improve the efficiency of your database. This command recreates the selected table and removes the unwanted local storage used by that table.

Query to optimize a table:

OPTIMIZE [NO_WRITE_TO_BINLOG | LOCAL]
TABLE tbl_name [, tbl_name] ...

This command reduces the amount of data stored in the memory and improves the performance of your site.

2.) Ensure your site uses Innodb storage engine for all databases

The two most popular database engines are MyISAM and InnoDB. Over recent years, the WP engine only supports InnoDB and converts all the tables using MyISAM automatically to InnoDB.

MyISAM performs precisely for database read operations, but it locks the entire table for writing or updating the database table. Until this individual process is done it prevents other read/write operations from starting in that table.

InnoDB over MyISAM: Reasons for choosing

  1. When you have multiple users, you will benefit from InnoDB row-level locking since it works to support multiple sessions on the same rows by locking them.
  2. It supports the foreign key constraints.
  3. It supports Atomicity, Consistency, Isolation, and Durability (ACID) properties.
  4. It also supports a large pool of buffer that caches both data and indexes.
  5. Uses transactional log to log every operation which helps in recovering the data quickly in case of any failure happens in the database.

If you are searching for a lightweight and less complex storage engine then you can use MyISAM since it is easier to manage.

For performance and data integrity you can select InnoDB which is a perfect choice for busy websites.

Please follow these steps to verify your storage engine:

Step 1: Login to the user portal in phpMyAdmin.

Step 2: Select the environment name.

Step 3: Click on phpMyAdmin

Step 4: Select the database (wp_environmentname)

Step 5: Check out the storage engine name in the Type column.

You can contact your host provider and ask if they can do it for you. But you can also do it by yourself with the simple alter command.

ALTER TABLE table_name ENGINE=InnoDB;

3.) Speed up search solutions

The problem with searching your data is that if you search for a lot of different things, it can take a long time to find what you're looking for. The solution is to use an index and use a search engine to quickly find what you're looking for.

The default search uses MySQL which is not search-optimized and slows down your website.

Elasticsearch is an open-source full-text search engine, noSQL database and is currently one of the most popular systems out there, used by a ton of big players in the tech industry.

Used to index the content of your WordPress site's database, it allows you to query the content of posts, pages, and custom post types promptly and efficiently.

WordPress usual search request

When the user searches for the string on the front or back-end of WordPress the PHP request pulls put data from the MySQL database through the sql query. The database, in response to the query returns data to the PHP handler.

ElasticPress is the plugin that integrates WordPress with the ElasticSearch client to make WordPress searching fast and awesome.

To install the plugin:

  • Click on the Add plugins button in the WordPress administrative dashboard and search Elasticpress in the search bar. You can also download the zipped version of Elasticpress from Github and upload it with the Upload plugin option.
ElasticPress
  • Click on install now and activate the plugin.
  • Activate and complete the setup with the ElasticPress.io credentials and endpoint that is emailed after you set up the account.

Instead of completing the form if you wish to maintain the configuration in wp-config.php file you can add the below lines in your configuration file.

define( 'EP_INDEX_PREFIX', 'demo-' );
define( 'ES_SHIELD', 'demo:icanhazpassword' );
define( 'EP_HOST', 'https://clusters.elasticpress.io:9999' );

Above are the basic installation and configuration steps. Check the ElasticPress site for indexing, testing and debugging your content.

4.) Autoloaded data

It is common practice in Wordpress to store information about the site's URL, themes and plugins in the database on each page request. This is called autoloaded data and is stored in the wp_options table.

The autoloaded data should be below 800,000 bytes (0.8Mb) for optimal performance. To reduce this you can disable the autoload for a row by simply setting the column to no. But this does not remove the data from the database.

With the help of the below query you, can find out which autoloaded data is sucking up the most memory.

SELECT LENGTH(option_value),option_name 
FROM wp_options 
WHERE autoload='yes' 
ORDER BY length(option_value) 
DESC LIMIT 20;

Using the above SQL query you can find out the length of each autoloaded column which will be displayed in bytes.

Always take a backup and then start disabling the autoloaded columns.

You can set the autoload option to "No" using the below query.

UPDATE wp_options SET autoload='no' 
WHERE option_name='option_name';

Ensure that your options table is indexed after reducing your total autoload data below 800k bytes. This helps your site to enhance the user-experience and serves fresh autoloaded data.

5.) Clean up WordPress Sessions

As WordPress continues to grow in popularity, the need to clean up sessions becomes critical. You will get millions of session rows in the _wp_session_ database. And if your table size exceeds or grows use the below query to find out the issue running in your WP site.

SELECT *
FROM `wp_options`
WHERE `option_name` LIKE '_wp_session_%'

To delete the session information using the query like the below one:

DELETE FROM `wp_options`
WHERE `option_name` LIKE '_wp_session_%'

Once you delete all the unnecessary data in the _wp_session_ it will reduce the size of the memory size and also fixes the performance bottlenecks in your WordPress site.

6.) Object Cache with Redis

Obtaining results faster is the purpose of any caching solution. It let you save them on trips to the database. The object cache stores all the cache data in the memory and content is available via a key, for further use.

WP_Object_Cache - It is the core class that implements the object cache.

Redis can be used to build fast, robust caching systems, implement highly scalable in-memory databases, implement data structures that are easily accessible from the inside of WordPress, to manage cache persistence between page loads and perform key-value lookups.

It is a relatively new technology, but it has quickly become a vital part of the WordPress ecosystem, due to its ability to be used in conjunction with WordPress’ native object cache.

Having a good, clean and persistent cache like Redis means the site will make your site load faster and the user will not have to wait for WordPress to make repeated database searches for the same content.

#9 Enhance background process

In general, background processes do not adversely impact website performance. However, excessive background processes, such as ones that are used for backup purposes and updates to plugins, can cause a website to become overloaded.

You may not even know what background processes are going on, or which are responsible for slow page loading speed.

To make a faster WordPress site and to make it more efficient, WordPress itself lets you schedule background processes to run on a schedule so that when you don't have access to the web, they still run the tasks in the background.

Look at the examples of background tasks that run on a WordPress site:

  • WP cron jobs to publish the scheduled posts and for checking updates
  • WordPress Backup plugin tasks
  • Trying to fetch content from search engines and other crawlers.

Cron job tasks will have minimal impact on your WordPress site whereas other WordPress backup plugins would ruin your site.

Always adjust the frequency of the backups and ensure that those plugins run only during the low traffic time on your website.

You can also use a SaaS-based full-stack monitoring solution to monitor the entire background process to take real-time backups that help you to boost loading performance of your WordPress site.

#10 Enable Gzip compression

Today, we compressed most websites to reduce their file size to improve the site speed and to boost the loading performance. This can be a problem, especially on slow connections, but if you use GZIP, then your site will be smaller and improves the loading speed of the WordPress site.

GZIP stands for GNU Zip, and it’s a popular method for compressing web content. GZIP compressed files are easier to download and distribute and are more secure than HTML pages.

Ways to enable Gzip compression in WordPress site

  1. Through .htaccess file
  2. By using a Gzip plugin
  3. With the help of the hosting provider

Enable Gzip compression through .htaccess file

One of the most commonly used methods to enable WordPress GZIP compression is through the use of a .htaccess file.

This method involves editing your site’s code, which comes with the risk of breaking something. The process is a bit more complicated than just changing a few lines in the core code.

Make sure you have a backup of your WordPress site before making any changes to the original code. Always save a copy of the original file to reduce the issues in your WordPress site.

The steps are as follows:

  • Login to the WP dashboard.
  • Open .htaccess file or any config file in Nginx.
  • Copy and paste the corresponding code based on the server type of your site.
  • Save the changes before closing.
  • And check whether Gzip compression is enabled or not with the help of your monitoring tool.

On Apache Server:

For sites hosted on Apache server, paste the below code in the configuration file.

# BEGIN 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>
# END GZIP COMPRESSION

To enable DEFLATE compression:

# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml

# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

On Nginx server:

If you have the Nginx server, paste the following code in the configuration file of your website.

gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_disable "MSIE [1-6].(?!.*SV1)";
gzip_vary on;

Enable Gzip compression via WordPress plugin

There are so many caching plugins available in the market that can help you compress HTML, CSS, and other JS files. With the help of the WP Gzip plugin, you can compress your HTML, CSS, and other JS files easily.

Plugins to enable Gzip compression:

  1. W3 Total Cache
  2. Pagespeed Ninja
  3. WP Rocket
  4. WP Super Cache

The above listed are the caching plugins whereas there are other WordPress plugins to perform these compressions.

Enable Gzip compression with the help of the hosting provider

Many web hosts enable Gzip compression by default. However, some of them, such as SiteGround, do not offer the ability to enable it automatically. Instead, they provide instructions on how to enable it.

Those who are not familiar with the compression process, can contact their web host provider and ask them to enable it for them.

Wrapping Up

In summary, you’re probably wondering "What do I need to do?" and the answer is pretty simple. Take a look at your website and figure out what’s slowing it down. Analyze the issues and ensure it doesn't affect your end users before making any changes to your site.

Here are some tips that will help you speed up your WordPress site, allowing you to optimize speed and performance in multiple ways:

a.) making a good first impression on search engines

b.) improving user experience

c.) increase engagement and conversions

d.) saving money by reducing your bandwidth and hosting costs

It's not just about speed, it's about converting faster. Find out the performance bottlenecks in your site and fix them as soon as possible with the help of your colleagues to deliver a better end-user experience and speed up your WordPress site.

Do check our blog on "How to find the performance bottlenecks in WordPress" and detect the issues before your end users identify them.


WordPress Performance Monitoring with Atatus

There is no doubt that the performance of the WordPress is one of the most important aspects of any website. To ensure your website is up and running smoothly, we at Atatus, provide a full-stack observability monitoring solution in real-time.

Atatus is easy to use, provides detailed results, lets you track the performance of your site and identify the potential performance issues to provide a better website to your users.

With Atatus APM you can easily find out which transactions are consuming the most of your time, slow transactions, HTTP failures, session traces, slow running queries, threatens causing third party API calls and other runtime metrics.

Get instant alerts about the performance bottlenecks and fix the issues as soon as possible with the help of your teammates.

Sign up and try Atatus for free!