1

I use a wordpress plugin to redirect my website to HTTPs however I have noticed a redirect time of 500 ms Which takes the time to first byte to 800 ms.

How can I reduce the redirect time?

  • Did you update all your links within your site to use HTTPS? In WP that is usually the "site address": codex.wordpress.org/Changing_The_Site_URL Once you do that, most users will never need to the redirect. – Stephen Ostermiller Oct 25 '17 at 11:40
  • 1
    Do you know if you are using php to redirect the page or if the redirect is made in your htaccess file on server? Typically it is faster to use htaccess to redirect. Php need to render its code first and then perform the redirect. – Kristian Svensson Oct 25 '17 at 11:41
2

How can I reduce the redirect time? I use a wordpress plugin to redirect my website to HTTPs...

Wordpress is generally driven by the PHP scripting language. PHP is 3rd party software that is called by your web server software when php files need to be processed and this is what goes on in the background (on the server) when someone requests a wordpress-based page.

Now depending on how bad the PHP code is, the processing time may take many milliseconds, or if the code is optimized and bug-free then the processing time may take maybe microseconds.

I do agree with one comment about managing redirects via .htaccess (provided your web server software is Apache). This is because the configuration file is processed by the web server directly with no 3rd party tool to load (such as PHP). This in turn makes processing faster.

One option, if you got the resources and/or money is to run the website on a server that only you can manage (such as a dedicated server), and shut off any applications and/or other services on that server that you don't need running.

I have noticed a redirect time of 500 ms Which takes the time to first byte to 800 ms.

This suggests to me any of the following are definitely true:

  1. The server you're using to host your website has serious memory management issues (to the point where it relies on the slow disk for memory access) and/or disk issues (to the point where there's damaged sectors). This can make the time to first byte extremely high.

  2. Any device connected between you and the server (including routers, switches, ISP, etc) may experience technical difficulties or you may be going through a large number of routers in order to reach the destination. Proof: Go on webpagetest.org and choose a location thats the farthest away from the server and have it access your page. you'll notice the initial loading time to be high which in this case is OK.

  3. Your server processes are downright intensive, and it might just be that plugin (aka php script) that's poorly optimized. If your server allows you shell access, use it and trace the PHP script to see why its taking alot of time to process simple work. If your server is linux, then the strace command will help here.

  4. You had millions of users accessing your page at once when you ran your tests. The server is able to process so many requests at once, then the rest are likely put on a queue until the first batch of requests are finished. Users in this queue can experience a higher wait time. If too many requests are made in such a short time then some connections may be dropped.

An answer

Having said everything, what I can suggest without you breaking budget and what-not is to scrap the wordpress plugin for HTTPs and use server configuration files (example .htaccess for apache) to define the redirects instead. You may want to look into mod_rewrite module if you use apache because its a helpful module that allows you to make friendly URLs and it allows you to redirect page requests matching a specific pattern to another URL. Nginx and other web servers may have similar modules but I'm not sure of the names of them since I use apache exclusively.

1

In addition to adding the redirect in your server configuration (.htaccess), you should also add a Strict Transport Security header to instruct browsers to directly request the HTTPS url without going via HTTP first.

Here's how you would set it in your htaccess:

Header set Strict-Transport-Security "max-age=31536000" env=HTTPS

Please read more about STS here: https://www.owasp.org/index.php/HTTP_Strict_Transport_Security_Cheat_Sheet

  • 3
    This will only have an effect for returning users (with the same browser), a new browser could still request the site on http first before they receive the STS header. – Zhaph - Ben Duguid Oct 27 '17 at 8:19
  • 1
    This should also be considered a "permanent" action, there is no going back to HTTP once you have enabled this (at least for the duration of max-age). – DocRoot Oct 27 '17 at 9:52
0

If you redirect from CloudFlare, then you can create a page rule there and put your redirect site. It will help to increase your site speed. Otherwise you can use wprocket you can see the tutorial in youtube how to avoid this redirect and you also remove these chain redirects by using semrush.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.