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?
Webmasters Stack Exchange is a question and answer site for pro webmasters. It only takes a minute to sign up.Sign up to join this community
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:
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.
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.
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.
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.
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.
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
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.