简体   繁体   English

预取是否适用于帖子短链接?

[英]Does prefetching works with a post shortlink?

I want to prefetch the next post in WordPress.我想预取 WordPress 中的下一篇文章。 In the admin panel and in the Permalink settings, permalinks are set to show Day and name :在管理面板和永久链接设置中,永久链接设置为显示Day 和 name

example.com/2021/12/25/post-1 example.com/2021/12/25/post-1

Does prefetching works using a post short permalink:使用后短永久链接进行预取是否有效:

<link rel="prefetch" href="http://example.com/?p=1">

instead of the regular post permalink:而不是常规的帖子永久链接:

<link rel="prefetch" href="http://example.com/2021/12/25/post-1">

Both are pointing to the same text/html request.两者都指向相同的text/html请求。 The short permalink ?p=1 is actually a 301 HTTP status code permanent redirect towards the regular permalink.短永久链接?p=1实际上是一个301 HTTP 状态代码永久重定向到常规永久链接。


prefetch through the short permalink (eg: /?p=1 )通过短永久链接prefetch (例如: /?p=1

<link rel="prefetch" href="http://localhost/www/wordpress/?p=1">

As it is a 301 , you will prefetch both.由于它是301 ,因此您将同时预取两者。 2 different text/html request will be made.将发出 2 个不同的text/html请求。

在此处输入图像描述

You can have a look at the network chrome console tab to test it on your own.您可以查看网络 chrome 控制台选项卡以自行测试。


prefetch through the regular permalink (eg: /hello-world/ )通过常规永久链接prefetch (例如: /hello-world/

<link rel="prefetch" href="http://localhost/www/wordpress/hello-world/">

Only 1 text/html request will be made.只会发出 1 个text/html请求。


In short简而言之

Both are doing exactly the same thing.两者都在做同样的事情。 One is more direct, and less performances heavy than the other.一个比另一个更直接,表演更轻。

You should have a look at the Prefetch MDN Web Docs and the Link prefetching FAQ to have a better understanding on how prefetch actually works.您应该查看Prefetch MDN Web 文档链接预取常见问题解答,以更好地了解prefetch的实际工作原理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM