大网数据广告活动
网站运营与故障问答

How to decrease HTTPs redirect wait time?

· 52CE 我爱测

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?

问题原文

原帖链接 · Computing Corn · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Mike -- No longer here · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。