How to improve your website speed? – Part 3
There are quite a few tips and tricks you could use to improve your website speed. We discussed in details some of them in our previous blog articles “How to improve your website speed? – Part 1” and Part 2. We have prepared for you today Part 3 as well. So, let’s see what else you might try.
1. Defer loading of JS files
2. Fewer redirects
When you minimize the HTTP redirects on your website, you will reduce the RTT (round trip time). Redirects take longer to be processed, so by diminishing their number, you will help the users access the information they need faster, improving their web experiences.
However, we should agree that there are lots of case, where using redirects is very important and quite useful. Their core purpose is to help the user reach a resource that has been moved to a new web location. Some of the top reasons for this:
- A change in the website domain
- Accessing the website from different domains
- Changes in the website structure and URL’s
- An update or maintenance
- Temporary access restrictions
- And more
However, it is advisable to avoid using redirects when possible, especially for the homepage of your website. Try to minimize their number and only use them when it is absolutely needed.
3. Turn Keep-Alive on
Keep-Alive uses the same TCP connection for every HTTP request instead of initiating different ones. In other words, it allows the browser to receive and load multiple different files at a time. To enable Keep-Alive, you need to edit the PHP code and add an HTTP header at the top:
header (“Connection: keep-alive”)
In case you do not have access to the web server config file, you can enable Keep-Alive by using a .htaccess file. Just add:
<ifModule mod_headers.c> Header set Connection keep-alive </ ifModule>
If you have access to the Apache config file, add the following:
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection. Set to “Off” to deactivate.
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
# KeepAliveTimeout: Number of seconds to wait for the next request from
# same client on the same connection.
4. Eliminate bad requests
Bad requests occur when an external source or user attempts to open a web resource that no longer exists or is distorted in any way. The server tries to process the request but fails. This has a negative impact on user experience and website speed. What can you do to avoid such situations?
Of course, we can not constantly know about everything that is going on with our website. Therefore, we recommend using tools and extensions that can automatically run tests and detect broken links, such as GTmetrix or the Crawl option in Google Search Console.
5. Asynchronous loading of Analytics and Ad Networks codes
You are most likely using some kind of an Analytics tool on your website (Google Analytics for example) or an ad network (like AdSense). Their codes, unfortunately, may additionally slow down the website. We recommend that you configure all tracking codes to load asynchronously. Thus, if the server of the external web services you are using is slow, it will not affect the website speed negatively.
6. Try a PHP accelerator
PHP accelerators are extensions developed specifically to improve the functionality and performance of any PHP software. They cache the PHP byte-code and so it will not have to be compiled over and over again with each execution request. They save CPU but slightly increase memory usage. Try to install OPcache and most likely your website loading time will drop in half.
If you have any questions, do not hesitate to contact our team at firstname.lastname@example.org. Our specialists are at your disposal!
November 23, 2018
September 10, 2018
August 16, 2018