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

Speed comparison - absolute vs relative path links

· 52CE 我爱测

Let's say I want to link to a parent directory ( http://example.com/library/ ) from a subdirectory ( http://example.com/library/html/basics/ ). The link to the parent directory can be: href="../../" href="/library/" href="http://…

问题原文

原帖链接 · Jakub Kliský · CC BY-SA 3.0

Let's say I want to link to a parent directory (http://example.com/library/) from a subdirectory (http://example.com/library/html/basics/).

The link to the parent directory can be:

  • href="../../"
  • href="/library/"
  • href="http://example.com/library/"

Is there a speed difference based on which way I write the link? I'm not asking about the website loading speed, but if there is a noticeable difference while traversing to the directory.

已采纳解答

原帖链接 · abhinsit · CC BY-SA 3.0

Effect for browser:

Though this looks like a bit of work for web browser, but technically it does not make much of a difference. The browsers are too fast to handle these relative url structure and make a call to application server

Effect for application Server:

None, as it needs to return the requested file (relative/absolute link ultimately maps to a web path)

Effect on page size:

Yes there would be some reduction in size (again not something that would make a huge difference to your page's performance that could be achieved by something like content encoding gzip or minifying resource)

So i think technically the absolute/relative urls dont make much of a difference on page speed / any weightable matrix.

Yes it make huge difference in managing multiple environments like dev, pp, prodpp etc

Example : on your local development you might have dev.example.com on pre production you might have : pp.example.com . .

So in those scenarios it would be relatively easy to manage code with relative urls (though can be managed by environment settings also)

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

资料来源与适用范围

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

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

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