Https性能:绝对vs相对URL [英] Https Performance: absolute vs relative urls

查看:82
本文介绍了Https性能:绝对vs相对URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需阅读有关绝对URL和相对URL 的问题,然后阅读一些有关该URL的文章.两者都各有利弊,造成极​​大的混乱.

Just reading an question about Absolute vs Relative URL and read some articles about same. Creating a great confusion, as both have there advantages and disadvantages.

我想知道在http(s)网站上使用相对或绝对URL会更好吗? (用于图片,CSS文件,JS文件等)

I would like to know what would be better to use relative or absolute urls on http(s) websites? (for pictures, CSS files, JS files, etc.)

对页面加载速度有影响吗?

Impact on page load speed?

对SEO有影响吗?

许多外部还是内部影响?

Impact of many external or internal?

推荐答案

简短回答

在http(s)网站上使用相对或绝对URL会更好?

what would be better to use relative or absolute urls on http(s) websites?

对于开发人员来说,相对URL 最适合内部资源,而绝对URL 是您的唯一选择用于外部资源.

For a developer, relative URLs are best for internal resources, and absolute URLs are your only option for external resources.

正如其他答案和评论所指出的那样,您的开发环境可能具有与部署(生产)环境不同的文件目录结构,并且两者可能会不时发生变化.如果在开发中使用相对URL ,则目录结构的这种更改将对项目视图几乎没有影响.

As the other answers and comments point out, your development environment will probably have a different file directory structure than your deployment (production) environment, and either may change from time to time. If relative URLs are used in development, such a change in your directory structure will have a little or no impact on your project views.

对网页加载速度有影响吗?

Impact on page load speed?

没有.对页面加载速度的影响受所引用资源文件的 number size location 的影响.您如何引用它们并不重要,因为仍然必须从Web服务器请求每个资源,然后Web服务器必须将响应(内容)反馈给浏览器以使用. URL是../assets/images/logo.png(相对)还是https://example.com/assets/images/logo.png(绝对)都没有关系.浏览器仍然必须去那里并获得它.这是浪费您时间的部分.

None. The impact on page load speed is affected by the number, size and location of the resource files referenced. How you reference them is immaterial, because every resource still has to be requested from the web server, which must then feed the response (content) back to the browser for use. It does not matter if your URL is ../assets/images/logo.png (relative) or https://example.com/assets/images/logo.png (absolute). The browser still has to go there and get it. This is the part that costs you time.

对SEO有影响吗?

Impact on SEO?

没有.并且出于同样的原因.两种情况下的目的地(位置)都是相同的,搜索引擎可以立即知道这一点,就像网络浏览器一样.

None. And for the same reason. The destination (location) is the same in either case, and the search engines know this instantly, just like a web browser does.

许多外部还是内部影响?

Impact of many external or internal?

太多(或太少)的资源链接对您的SEO的影响需要进一步讨论和研究.为了我们的目的,我想指出的是,没有外部资源的相对URL 这样的东西.此外,对SEO的影响不太可能是内部资源的不同之处在于其相对绝对引用(URL).

The impact of too many (or too few) links to a resource on your SEO is a matter of further discussion and study. For our purposes here, I want to point out that there is no such thing as a relative URL to an external resource. Further, the impact on SEO will not likely be any different for internal resources on the basis of its relative versus absolute references (URLs).

这篇关于Https性能:绝对vs相对URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆