How to Speed Up WordPress and Boost Performance on an Ubuntu 20.04 VPS

WordPress is one of the most popular open-source content management systems around the globe. It’s one of the easiest blogging platforms to get started with, as evidenced by over 35.2% of all websites being powered by WordPress. If you are already a webmaster or a blog owner, then speeding up and boosting the performance of your website should be one of your top priorities. In this tutorial, we will show you some useful tips to speed up any WordPress website, as well as explain why it’s important to do so.

There are several reasons why you should speed up your WordPress website.

Search engines (like Google) now include site speed in their ranking algorithm, which means the websites with faster loading times will rank more highly than websites with slower load times. According to the Microsoft Bing search team, only a 2 second delay in page loading will reduce user satisfaction by 3.8% and reduce clicks by 4.3%. Website speed will also impact on your online business and reduce your site visitor.

Use a Content Delivery Network

CDNs, also known as a Content Delivery Networks are a network of servers located around the world designed to host and keep a copy of your website in various data centers located in different geographic locations. A  CDN serves your WordPress site’s static content such as images, CSS, JavaScript, and video streams to a visitor from the nearest possible location. The location closest to your site visitor is what will serve the content – the close location allows for lower latency and faster load times, regardless of the visitor’s location.

Optimize images

Images bring life to your content and help you to increase your website visitors and make your sites more content-rich. Image optimization is another trick you can do which will have a significant impact on your overall page load times.

Unoptimized images will slow down your website, no matter what. To prevent this, before uploading any images, you should reduce the size of the images without compromising on the quality. You can decrease your image size by up to 5x using any compression software like Adobe Photoshop or Affinity Photo. However, you can also perform these tasks automatically through the use of WordPress plugins. Having smaller image sizes will allow for faster load times, which ensures that your page times won’t be hung up by waiting for a large photo to load.

There are several file types you can choose before compressing images like, JPEG and PNG. You should use JPEG for images with lots of color and PNG for simple images, or ones that need background transparency.

Keep Your WordPress Site Updated

Another tips to increase your site speed is to update WordPress regularly. Each update will not always offer new features, but it will fix bugs and security issues. So it is recommended to keep your WordPress site, theme, and plugins updated to the latest versions. Additionally, if you use WordPress VPS Hosting, keeping your server packages (like your PHP version) updated is important in keeping everything as snappy as possible.

Use a Lightweight Theme

There are lots of themes available in the WordPress market. Avoid using themes with a lot of dynamic content, such as widgets, sliders, sidebars, etc. Using them in moderation may be okay, but having lots of elements shown at one time can really take a toll on loading speeds. It is recommended to use a lightweight theme or an optimized theme at the very least. If you want more features while maintaining performance, then you should use themes that are built on Bootstrap and Foundation.

Disable Hot-linking

Hot-linking is a form of bandwidth. It occurs when other websites serve your images directly from their URLs on your website, instead of uploading them to their own servers. In simple terms, they steal your web hosting bandwidth and you don’t get any traffic coming to your pages.

To prevent this, you just need to add the following code to your WordPress .htaccess file. This will prevent other sites from using your images on their pages.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourdomain.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?feeds2.feedburner.com/yourdomain [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]

Use the Latest PHP Version

WordPress is written in the PHP language – which means that all WordPress instances use a PHP hosting server. Sometimes, it is possible that your hosting company is running an older PHP version, or your server simply has an outdated version installed. Usually, the latest PHP version is faster and more secure than its previous version. Make sure to keep your PHP version up-to-date to help boost the performance of your website.

Disable Unwanted Plugins

There are lots of plugins available on the WordPress market. Installing unwanted plugins on your WordPress websites may affect your site’s performance. Having additional unnecessary plugins installed will also increase the size of your backup and put a larger amount of load on your server while taking a backup or serving website content. So it is recommended to uninstall any unnecessary plugins from your WordPress website.

Cleanup WordPress Database

Whenever you install WordPress plugins or themes, new tables are added to the database. After deleting unused plugins, the tables stay behind. This will increase the size of the WordPress database over time and may impact WordPress’ database performance, and in conjunction, your website performance. This makes it a good idea to clean up your WordPress site regularly. Your database accumulates a lot of extra data, such as revisions, spam comments, trashed comments, data from plugins you are no longer using, and more. Database cleanup process removes all of this unnecessary data. This can significantly reduce your database size which speeds up your backup process.

Enable GZIP compression

GZIP is a file format and software application used for file compression and decompression. It is enabled on the server-side and reduces the size of your HTML, stylesheets, and JavaScript files. Enabling GZIP compression will dramatically reduce the bandwidth usage and the time it takes to gain access to your website.

To enable GZIP compression, just add the following lines to your WordPress .htaccess file:

<IfModule mod_deflate.c>
  # 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
</IfModule>

Enable Leverage Browser Caching

Browser caching is a technique that allows a browser to store cacheable resources such as, CSS, JavaScript, and Images locally for a certain period of time. This allows the browser to only need to download the updated/new resources when accessing the same website again. This will help in reducing HTTP requests, which load pages faster and also improves server response time.

If your website is hosted on the Apache web server, you can enable the leverage browser caching by adding the following lines in your WordPress .htaccess file:

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpg "access 1 year"
  ExpiresByType image/jpeg "access 1 year"
  ExpiresByType image/gif "access 1 year"
  ExpiresByType image/png "access 1 year"
  ExpiresByType text/css "access 1 month"
  ExpiresByType text/html "access 1 month"
  ExpiresByType application/pdf "access 1 month"
  ExpiresByType text/x-javascript "access 1 month"
  ExpiresByType application/x-shockwave-flash "access 1 month"
  ExpiresByType image/x-icon "access 1 year"
  ExpiresDefault "access 1 month"
</IfModule>

If your website is hosted on the Nginx web server, add the following lines in your Nginx virtual host configuration file:

location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
  expires 365d;
}

Limit Post Revisions

When you save a new post or page in WordPress, it creates a revision. This will help if you need to revert the post to the previous version. However, post revisions take up space in your WordPress database. This will slow down your site by searching them unnecessarily. Therefore it is recommended to limit or disable the revisions altogether. Limiting them would be ideal if you need to quickly go through previous iterations of your content.

To limit revisions, you can add the following code to your WordPress wp-config.php file.

define('WP_POST_REVISIONS', 5);

To disable revisions, you can add the following code to your WordPress wp-config.php file.

define('WP_POST_REVISIONS', false);

Use a Caching Plugin

Caching is one of the simplest and easiest methods to speed up your WordPress site. Caching tells the server to store files such as images, CSS, and JavaScript to the disk or RAM. When any user revisits the same page again, content can be served from the cache. This will reduce the amount of work required to generate a page view and your web pages will load much faster, directly from the cache.

If your hosting provider doesn’t provide a cache, you can use one of several third-party WordPress caching plugins, including WP Rocket, Cache Enabler, or W3 Total Cache.

These are the best ways to improve the performance of your WordPress site. By combining these, there should be a noticeable difference in the responsiveness and speed of your website, which will also help boost your rankings in search results.


Of course, you don’t have to speed up your WordPress on your Ubuntu 20.04 server by yourself if you use one of our Managed Ubuntu Hosting solutions, in which case you can simply ask our expert Linux admins to speed up and optimize your WordPress instance for you. They are available 24×7 and will take care of your request immediately. You might want to consider reading our post regarding How to Improve the Speed and Rank of a WordPress Website.

PS. If you liked this post on how to optimize and speed up WordPress on Ubuntu 20.04, please share it with your friends on the social networks using the share shortcuts below, or simply leave a comment in the comments section. Thanks.

Leave a Comment