linkcheck icon indicating copy to clipboard operation
linkcheck copied to clipboard

Handle preconnect links correctly

Open filiph opened this issue 5 years ago • 4 comments

<link rel="preconnect" href="https://www.googletagmanager.com" /> is a hint to start DNS lookup and so on, for the domain. The actual page can be 404.

Current status:

  • Preconnect links are considered like any other link, being fetched / HEAD-ed when -e.
  • For the specific example of <link rel="preconnect" href="https://www.googletagmanager.com" />, this means a HTTP 400 error is reported (because https://www.googletagmanager.com is not a valid page).

Ideal solution:

  • Preconnect is recognized and linkcheck then merely verifies that the domain exists and connects.
  • linkcheck might show a warning when there's a preconnect link and then no actual link to that domain. (Problem: many times the actual link is constructed in JavaScript.)

Realistic solution:

  • Preconnect links are ignored. After all, it is just a hint, and sooner a later an actual link is coming.

filiph avatar May 30 '19 05:05 filiph

Same is true for <link rel="dns-prefetch" ...>. I also propose to just ignore those.

thomasbachem avatar Apr 09 '20 14:04 thomasbachem

dns-prefetch and preconnect seem to be the only ones one should ignore (source).

So the selector should not be link[href] but link[href]:not([rel~='preconnect']):not([rel~='dns-prefetch']).

thomasbachem avatar Apr 09 '20 14:04 thomasbachem

@filiph Any updates on this? Is there a workaround with the latest version to just ignore preconnect links?

levesquejf avatar Oct 30 '20 16:10 levesquejf

Sorry for the late reply. There is no workaround with the latest version but if you build linkcheck with the development version of Dart, you should get the behavior you expect. Sorry for not being more helpful — can't really sink more time into this at the moment.

filiph avatar Nov 07 '20 05:11 filiph