how to speed up a website on debian 9

How To Speed Up a Website on Debian 9

Spread the love

speed up website debian 9Speeding up a website is a very important process because most of the visitors will leave a slow website and visit a competitor’s website instead of suffering a delay. Also, they would not return to a website with poor loading speed. A faster page load speed gives visitors a better user experience. The impact of website speed is huge on search engine rankings too. If you strive to achieve good rankings on search engines, make sure to optimize your website for speed. Before we start working on improving the website speed, it is a good idea to know what is an acceptable web page speed. In general, the best practice is around three seconds.

There are many different steps we can take to increase website speed and improve user experience. In this guide, we will show you how to speed up a website on a Debian 9 VPS.

Listed below are the most efficient ways to increase the website speed:

Enable GZIP compression

Enabling website compression allows the web page to load faster, so if you have Apache2 installed and running on your Debian VPS, enable Gzip module (mod_deflate) using the following command:

sudo a2enmod deflate

Restart the Apache service for the changes to take effect:

service apache2 restart

Create a .htaccess file in the document root directory of your website (or modify it if it exists) and add the following code in it:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/
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
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

Enable Expires Header to static resources

When visiting a website, the website will cache in the visitor’s web browser. Adding Expires headers to static resources is useful because it reduces the web page loading speed for subsequent page views/return visits from returning visitors. In order to enable Expires headers to static resources, we need to add the following code in the .htaccess file:

ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000

Where A2592000 means 1 month.

Use a Content Delivery Network (CDN)

Using a CDN is a great way to achieve a better user experience and reduce the load speed of a website. When using a CDN, the website files are cached on many servers in different locations of the world and whenever a visitor accesses your website, the requests to your website are served from a nearby server.

Use advanced caching mechanisms

Use a caching mechanism that works efficiently to optimize your website for speed. By enabling a caching mechanism, we can reduce the time it takes for repeat visitors to load the website. Depending on the website content (static, dynamic, and/or database-driven), we can install and use Varnish, Redis, Memcached, etc. All caching mechanisms allow web applications to store data and recall it from memory very fast. Also, if you use a CMS on your website, try to install a caching plugin/extension.

Minify JavaScript and CSS files

Minify all JavaScript files over 4 KB of size.

Remove all unused CSS code. Minify the CSS code by stripping out unnecessary characters and spaces thus reduce its file size.

Load the CSS code inside the <head> element, and JavaScript code inside the <body>, usually to the bottom of your web pages.

Optimize Images

Larger images take longer to download than smaller ones. Try to use smaller images, and keep the number of images to an absolute minimum. Use images in an appropriate format. such as JPG, SVG, PNG, and GIF format.

Optimize the database

To optimize the website loading time, it is important to optimize the MySQL database used by your website too.

If you use a MySQL database on your website, use the following command to optimize it:

mysqlcheck -u<db_user> -p -o <db_name>

Replace <db_user> with the actual MySQL username and <db_name> with your MySQL database name respectively.

Remove Unnecessary Plugins and Add-ons

speed up website debian 9If you use a CMS on your website, try to delete all unused themes, extensions, plugins, add-ons, etc. Of course, you don’t have to speed up your website on Debian 9, if you use one of our Linux server management services, in which case you can simply ask our expert Linux admins to help you speed up and optimize your website for you. They are available 24×7 and will take care of your request immediately.

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

Leave a Reply

Your email address will not be published. Required fields are marked *