How to Speed up and Optimize WordPress

How to Speed up and Optimize WordPress

We’ll show you, How to Speed up and Optimize WordPress. Doesn’t matter if you are running a small blog or a high-traffic website based on WordPress, optimizing your WordPress should be one of your top priorities. Page speed is so important today that even Google’s ranking algorithm has been adapted to this. Moreover, a slow site means less visitors and that is the main reason you should be concerned about. In this post, we will do an overview of some of the key optimization techniques that could help your to get the best performances of your WordPress site and your Linux VPS.

The WordPress optimization techniques will be limited by the hosting service you are using. If you are using shared hosting then you will have little control over your server setup and you will not be able to perform advanced optimization techniques. Note that many managed VPS providers won’t give you full control (root access) to your VPS. That is why we always recommend using our Linux VPS hosting powered by enterprise SSD drives to run a WordPress web site. If you get a VPS from us, you will have full control (root access) over the server to perform server-side optimizations. We recommend switching from Shared to VPS ASAP. You’ll see a lot of improvements of your site’s performance, even by switching to a VPS alone, without any further optimizations.

01. LEMP (Linux, Nginx, MySQL/MariaDB and PHP)

Using a solid software stack like LEMP will certainly help you to get the best of your WordPress installation. The LEMP stack consists of Nginx which is used to run the busiest sites on the Internet. It will significantly improve the performance of your WordPress site and your server. If you don’t have LEMP installed on your WordPress server, go ahead and install Nginx, MySQL and PHP-FPM using our guide. You can find more performance improving tips about WordPress and Nginx. Running the latest version of the software is very important too, so make sure that all your WordPress code, Nginx and the other server software are up to date. Updating your PHP to PHP 7 will be very beneficial too as PHP 7 is considered as twice as faster than PHP 5.6. Also, according to some benchmarks, PHP 7 uses 30% less memory and serves 3x more requests.

Reducing the server load by disabling the unused services running on it will have a huge impact on the performance of your site. The server will handle more traffic without crashing some of the important services like your database server.

02. Caching

Caching is very important if you like to speed up your WordPress site. By implementing some good caching techniques you can improve the performance several hundred times. We will review some of the most effective caching techniques.

03. Server-side Caching

Adding an opcode caching like OPcache to your PHP will improve its performances significantly. This is very simple method as OPcache comes with the PHP core by default. Just make sure that your PHP version is greater than 5.5, although we recommend using PHP 7 with WordPress.

04. Caching Plugins

To cache your WordPress posts and pages as static files you can can use some caching plugin. Installing a caching plugin in WordPress is fairly simple, just as any caching plugin in WordPress. However, you may need to take care of the post-installation configuration. Almost all caching plugins provide user documentation so you can. easily learn how to configure the plugin for maximum performances. You can check our tutorial for w3 total cache.

The caching plugin category for WordPress is available at https://wordpress.org/plugins/tags/caching.

05. Leverage Browser Caching

Another caching technique that you can implement for your WordPress site is to leverage browser caching. Browser caching means the client’s web browser will download and store the assets like CSS, JS and images into the local storage for a certain amount of time, which can reduce the number of requests for each page and will greatly reduce the server load. To enable leverage browser caching simply add the lines below into your .htaccess file:

## EXPIRES CACHING ##
<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>
## EXPIRES CACHING ##

If you are using Nginx instead of Apache as a web server, add the following lines in the server block for your domain name:

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

[ecko_alert color=”blue”]Want us to do all of this for you? Get a VPS from us and we’ll fully (and properly!) optimize your WordPress site and your server. Free 24/7 managed support is included in all of our hosting plans. [ecko_button color=”green” size=”normal” url=”https://www.rosehosting.com/wordpress-hosting.html”]Get a Managed WordPress VPS[/ecko_button][/ecko_alert]

Other WordPress optimization techniques

Many of the techniques we mentioned earlier cannot be performed if you are on a shared hosting as they are server-side optimizations and require special access to the hosting environment. That is not the case with the ones that follow. You can do the following optimizations even on a shared hosting account

06. Add gzip compression

Gzip compression is necessary in order to decrease the size of data that is being sent from your server. Enabling Gzip compression is fairly easy, just add the lines below into your .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>

In case you are using Nginx, add the following lines in your your Nginx configuration file:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS
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;

# Disable for IE < 6 because there are some known problems
gzip_disable "MSIE [1-6].(?!.*SV1)";

# Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
gzip_vary on;

07. Use only essential plugins

Using plugins in WordPress is essential, but you need to be aware that using unnecessary plugins and plugins which are coded inefficiently may affect your site’s performance. So, our recommendation is to install and enable the WordPress plugins that you truly need for your project as well as to make sure that those plugins are not slowing down your site.

08. Use good themes

If you are using a well-coded theme for WordPress site you are more likely to have a fast-loading website. Some theme developers tend to include fancy effect on their products which always comes at a cost. There are so many well-coded WordPress themes out there, both free and paid, that wait to be found. You just need to do a quick research and you will likely select a theme which will help you to speed up the loading time of your WordPress site.

09. Optimize images

Yes, images are important. But, think about how badly the images can affect the loading speed of your website. Unoptimized and large images will load slowly which could cause the visitor to leave the site. To save time, bandwidth and improve your search engine ranking you need to take care of the graphics displayed on your website. Optimize the images by using some of the WordPress plugins developed for this reason, like WP Smush for example.
If you have troubles with optimizing graphics, try to consider whether images are necessary to represent something. Maybe you can reduce the number of images by replacing them with text.

10. Minify CSS and JavaScript files

Minifying the CSS files could be good, especially if you are not able to combine them into a single, optimized file. The same applies for the JS files. Likely, there are many plugins that could help you with this, including our previously-mentioned plugin W3 Total Cache.

11. Content Delivery Network

Sometimes the geographical distance between the server where your website is hosted and your website visitors can influence the loading speed. A common solution for this problem is using a Content Delivery Network or CDN. By using a CDN service you can offload the static files as well as the images so your website visitors can have better experience. This will reduce the server load and will significantly improve the site’s performance.


Of course, you don’t have to Speed up and Optimize WordPress, if you use one of our WordPress Hosting services, in which case you can simply ask our expert Linux admins to help you speed up and optimize your WordPress site. They are available 24×7 and will take care of your request immediately. We also published an updated post on How to Speed Up WordPress and Boost Performance on an Ubuntu 20.04 VPS.

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

2 thoughts on “How to Speed up and Optimize WordPress”

  1. Using a CDN is mentioned and invaluable. I would also recommend using a redis cache which is fairly simple and speeds loading times up massively.

    Reply
    • Hello. Yes, Redis cache can be used too. Our guide at https://www.rosehosting.com/blog/install-and-run-wordpress-cached-with-redis-on-linux-vps/ will help you to set up Redis cache with WordPress.

      Thanks.

      Reply

Leave a Comment