Home > Software engineering >  Does prefetching works with a post shortlink?
Does prefetching works with a post shortlink?

Time:12-26

I want to prefetch the next post in WordPress. In the admin panel and in the Permalink settings, permalinks are set to show Day and name:

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">

CodePudding user response:

Both are pointing to the same text/html request. The short permalink ?p=1 is actually a enter image description here

You can have a look at the network chrome console tab to test it on your own.


prefetch through the regular permalink (eg: /hello-world/)

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

Only 1 text/html request will be made.


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.

  • Related