Вопрос

Is there a speed difference between apache loading "http://mywebsite.com" and "/"?

Does the former actually pull data across the WAN? I've noticed if I ping "mywebsite.com" it's slower than if I ping "localhost", but does this apply to apache when loading the pages from a clicked link?

Это было полезно?

Решение

localhost typically resolves to ip address 127.0.0.1 (the loopback interface). For other domains, your OS needs to lookup the corresponding IP address in a DNS service, and then execute the remote ping, http operation, etc... I would expect each interaction with an external service to add latency, compared with a corresponding internal operation. Sometimes these DNS values can be cached so that the lookup penalty is only paid once and a while. As for the speed difference to resolve and access a URL, that depends on the client logic, but is probably negligible. One key advantage of relative paths is that your service is not aware of its deployment and can be lifted and moved elsewhere without changing a bunch of URLs.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top