Impact of Redirects on Web Page Speed
A common myth is that redirects can slow down a webpage. It is true that redirects can add an additional overhead to the loading time of a page, but their impact is generally insignificant. However, depending on how they are implemented, this myth can be partially true.
I have often heard the argument that redirects should be avoided because they affect performance. This is said out of ignorance, and we will delve deeper into this topic here.
Properly implemented redirects, such as 301 redirects (permanent) or 302 redirects (temporary), are processed quickly. However, if they are misconfigured or chained, they can indeed have a negative impact on performance, consequently increasing loading times and generating additional requests to the server.
It is important to highlight that redirects are necessary in many situations, such as when a website's structure is changed. Therefore, a proper redirection strategy can prevent traffic loss and maintain SEO integrity without harming the user experience. In fact, they are more than necessary during migrations.
Ideally, all redirects should be made from the same place and in an orderly manner for future maintenance. This way, redirect chains can be avoided, and control over them can be maintained.
I firmly believe that this myth may have originated from the misuse of the .htaccess file, especially on Apache servers (which was the most commonly used server at the time the myth was created). The reality is, .htaccess is often used incorrectly.
In SEO, there are numerous beliefs that can influence the design and optimisation decisions of a website. One of these is the idea that excessive use of redirects in the .htaccess file can slow down a website's performance. However, it is crucial to understand that the actual impact of redirects on web performance is more complex than commonly believed.
More than the issue of redirects, it is due to the use of this type of file.
You should avoid using
.htaccess
files completely if you have access to the main httpd configuration file. Using.htaccess
files slows down your Apache HTTP server. Any directive that you can include in an.htaccess
file is better set in aDirectory
section, with the same effect and better performance. — Apache Documentation
Before delving into the impact of redirects in .htaccess, it is important to understand the function of this file in the web development environment. This file is a powerful tool used on Apache web servers to configure various server options, such as redirects, access control, file compression, and more. It allows developers to modify server settings without needing direct access to the main server configuration.
We can understand it as an appendix used by both Apache and LiteSpeed. The advantage is that there is no need to access the main server configuration or restart the server. On the downside, this means the server needs to read these directives every time a user makes a request to the server. If these directives are lengthy and cumbersome, the server will take longer to process each request. If there are many users requesting from a server with an .htaccess file containing too many directives, it can cause loading issues.
In other words, .htaccess is read "at run-time," live, while other server configurations are preloaded, making it more efficient.
Let’s examine various sources regarding the effect .htaccess has on performance.
SEOMike conducted testing on redirects, where there was a noticeable impact after 30,000 redirects.
However, this was using .htaccess with Apache, i.e., in the worst-case scenario. If the claims in the documentation and my own tests are correct, the low performance is due to the abuse of .htaccess, not the excessive number of redirects.
NETSeven also conducted a comprehensive study on the subject.
The main conclusions of this analysis on the impact of using .htaccess files on an Apache web server are:
In summary, although the use of .htaccess files offers flexibility, it also comes with a performance penalty that should be considered, especially in high-traffic configurations or when using large and complex configuration files.
Strategiq also conducted their own analysis on the subject.
The analysis in the StrategiQ article on the impact of the number of rules in .htaccess files on server performance and scalability reveals several key points:
This analysis highlights that the more rules contained in an .htaccess file, the greater the impact on server performance and scalability, which is crucial to consider in production environments where efficiency is critical.
In Matthew Edgar's article on redirects and their impact on website speed, it is concluded that redirects can significantly affect speed, especially through Time to First Byte (TTFB).
Redirect chains, where one page redirects to another successively, can add considerable loading time.
Additionally, redirects specified in an .htaccess file can increase server overhead if there are many of them, which also reduces site speed.
The article recommends minimising redirects and optimising redirect management to improve website performance. However, my conclusions remain that it is due to the abuse of .htaccess and the implications of the redirect chains themselves.
In any case, as we observed with SEOMike, there isn’t a significant change in performance until the redirect count reaches 30,000 lines.
Even though there may be an impact, all the tests observed on servers not using .htaccess to generate redirects show minimal impact:
You can analyse your own redirects with a redirect speed tester or you also have the option to analyse web performance (without needing a redirect or anything) by adding a lot of code to your htaccess file.
The reality is that it makes sense that the excessive code the server has to process every time it receives a request is what affects performance.
Redirects themselves have minimal impact on a website’s performance and speed. The key is to adopt good practices by understanding the nature of servers.
.htaccess should only be used for auxiliary code that needs to be implemented quickly. And although web speed can be optimised with commands in .htaccess, this is achieved simply because what those codes do improves speed more than the added weight of the file due to the increased number of lines.
Redirects do not slow down a website. But codes in .htaccess or a PHP file called throughout the site do. The problem is not the number of redirects but how they are implemented.
I currently offer advanced SEO training in Spanish. Would you like me to create an English version? Let me know!
Tell me you're interested