Optimize WordPress Site to improve performance
WordPress is the most commonly used Content Management System (CMS) for the websites all around the world. Optimizing the website performance is a challenging task for all webmasters. Main topic is reducing the loading time and speed up the site, as per Google analysis a slow loading site can affect your SEO rankings. There are so many ways to optimize the WordPress site performance. In this blog we are talking about a few steps to optimize the WordPress site performance. Let's see what are they.
Update WordPress to the latest version
Most important part is to update the WordPress and its plugins and themes to the latest version. This will increase your site performance and decrease the vulnerabilities. To update, log in to your WordPress admin panel, go to the Dashboard > Updates. You should see a page like this:
In the above page, you should see that WordPress and all your plugins and themes are up-to-date. If any updates are available, you should see the message “An updated version of WordPress is available” in the above page.
Enable Gzip Compression
Enabling Gzip compression for your WordPress site will reduce server response time and volume of data sent by the server to a web browser. GZIP is a file format and application that can be used for file compression and decompression. GZIP compression allows you to reduce the size of your HTML, stylesheets, and JavaScript files. This will significantly reduce the amount of time to download the resource, reduce data usage and improve the page load time. You can enable Gzip compression by editing .htaccess file from your WordPress root directory. Enabling Gzip compression in WordPress using .htaccess file will reduce server response time and volume of data sent by the server to a web browser. Go to the WordPress root directory and Open your .htaccess file with the following command:
Add the following lines for WordPress running with Apache web server:
<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>
Or add the following lines for WordPress running with Nginx web server:
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;
Save and close the file, when you are finished.
Configure Expire Headers
With expire headers, your browser can check whether it should request the website assets from the server or fetch them from the browser cache. For example, we set an expire headers value for our logo.png file to one month, so the browser will cache the logo.png file and it doesn’t need to request the file as the browser already have it in the cache. Expire headers can reduce the HTTP connection and improve the site loading speed at the same time. If you use apache, you can add the following lines to your .htaccess file:
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
If you are using nginx, you can add this line to your location block:
if ($request_uri ~* ".(ico|css|js|gif|jpe?g|png)$") {
expires 30d;
access_log off;
add_header Pragma public;
add_header Cache-Control "public";
}
Clean Up WordPress Database
WordPress database accumulates a lot of extra data including, trashed comments, spam comments, unused plugins data and many unnecessary data. It is recommended to clean up your WordPress database regularly to remove all unnecessary data to improve your website performance. Regular clean-ups reduce your database size and speed up your backup process. It is a good way to optimize your WordPress site.
To clean up your database, you will need to install and activate WP-Sweep plugin. After installing WP-Sweep plugin, go to the Tool > Sweep. You should see a page like this:
Image :2
You can clean up your data one by one or click on the 'sweep all' button on the bottom of the page to clean up all the data in your WordPress database.
Split Comments Into Pages
If your blog is getting a lot of comments, this can be causing page leg. The blog posts with a lot of comments load slower than other posts. Many comments increase your server load time and also decrease your SEO rankings. So it is recommended to break the comment section into pages to save off the time it takes for them to load.
To split the comments, go to Settings > Discussions. Then, choose the number of comments you want per page.
Disable/Remove unwanted plugins
Keeping unwanted plugins on your WordPress websites will add a tremendous amount of junk to your web files. Moreover, it will also increase the size of your backup and put an overwhelming amount of load on your server resources while backup files are being generated. It is better to get rid of the plugins that you don’t use and also look for alternate methods to use third-party services for automating or scheduling tasks (like sharing of your latest posts to social media). To disable/remove unwanted plugins, go to Plugins > Deactivate/Delete
Use a CDN
A content delivery network (CDN) is a geographically distributed servers and data centers. CDN provides high availability and high performance by delivering pages and other web content to a user based on the user’s geographic locations. The users visit your site from the different locations around the world. The website loading speed will differ if the users are located far away from where your site is hosted. Content Delivery Networks (CDN) keeps a copy of your website in different data centers located in different locations and serve the web page to a user from the nearest location. So it is recommended to add your website to CDN like, Cloudflare, MaxCDN, Rackspace and Cachefly.
In this blog we have talked about some tips and tricks to optimize your WordPress site. I hope you have now enough knowledge to boost your WordPress performance. This will also increase your rankings in the SERPs and improve the experience of your visitors.