resource-hints | Resource Hints | Awesome List library
kandi X-RAY | resource-hints Summary
kandi X-RAY | resource-hints Summary
Resource Hints
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of resource-hints
resource-hints Key Features
resource-hints Examples and Code Snippets
Community Discussions
Trending Discussions on resource-hints
QUESTION
I have a site, that uses a 302 redirect for new visitors to establish a new session. I've created a demo of the basic flow on my personal site:
- https://crenshaw.dev/redirect/index.php (302)
- https://crenshaw.dev/session/redirect/index.html (200)
index.html uses resource https://mac9416.com/demos/style.css
(I just needed an external domain name).
I want to instruct the browser to connect to mac9416.com in the 302 rather than the 200.
Potential solutionSome browsers support resource hint headers. Here are some examples:
What went wrongEXAMPLE 5
Link: https://widget.com; rel=dns-prefetch
Link: https://example.com; rel=preconnect
Link: https://example.com/next-page.html; rel=prerender;
Link: https://example.com/logo-hires.jpg; rel=prefetch; as=image;
Dev tools shows the Link
header in the initial request:
I see the connection to mac9416.com established after the 200, immediately before the resource is downloaded.
I expected to see the connection established immediately after the 302, or simply missing from the timeline.
I tested using Chrome 73. The WebPageTest waterfall looks almost identical.
Note: I'm interested in server-push solutions, but for now the site in question runs HTTP1.1.
The questionAm I attempting something that isn't even supported? Must resource hint headers be served on non-redirect responses only?
The "Anonymizing redirect" section of the resource hint working draft leads me to believe it's meant to help in exactly my type of situation. But maybe I'm misreading.
...Many sites rely on redirect services for analytics, malware protection, and to anonymize the referrer before sending the user to the final destination. Because the destination is known ahead of time, a preconnect hint can be used to initiate the connection handshake with the destination origin (without revealing any private information) in parallel with the processing of the redirect - this masks the redirect latency and reduces navigation time to final destination.
ANSWER
Answered 2019-Mar-29 at 01:38Well I checked out your experiment (thanks for knocking that up!) and couldn't see anything wrong with it. I also repeated it myself on my own server and can confirm your findings: none of the major browsers seem to support resource hints across page redirects.
As to the paragraph from the draft spec you point out, I can think of two explanations:
- This is a potential use case and the browsers are just not supporting it (yet).
- This wording is more intended for resources on the current page that have to go through a redirect first. So if for example the current page (index.html) loads
www.example.com/latest/framework.js
and that redirects tocdn.example.com/latest/framework.js
to actually load this resource. It's notable that only prefetch and prerender explicitly note they are meant for the "next navigation" (though I tried those two out of interest and they also don't work for the redirect scenario).
Either way I agree it could be clearer. I was going to suggest opening an issue on Github but see you already did that! Hopefully the spec authors can confirm this.
Incidentally I tried with a JavaScript redirect instead of a 301/302 and it worked in Chrome for both HTTP link header and HTML link instructions for preconnect - suggesting again that only 200 responses are looked at for resource hints.
An interesting question you raised! Not sure if off topic for StackOverflow but certainly piqued my interest...
QUESTION
I am trying to use, as correctly as possible, browser resources hints (https://w3c.github.io/resource-hints/).
I went on a few large websites and most of them specify the http/https protocol such as like this:
...ANSWER
Answered 2018-Feb-12 at 09:00I wondered if not specifying if it's either http or https could have a impact/cost as the browser will have to fetch more information (one for http, one for https) like 2 dns information ?
No, the browser does not have to make two requests.
This is called a protocol relative URI - the browser will complete it to a full, absolute one using the protocol that the page this was embedded into was requested with.
If you requested the page this is embedded into using https://
- then //foo.bar/
will become https://foo.bar/
; if you used http://
only, then it will become http://foo.bar/
This is a means to allow site authors to write their code in a “protocol agnostic” way. You can deploy a site using this to refer to external resources so that it can be reached either via HTTP or HTTPS, without having to modify all those references. And it helps prevent problems that might arise when you transfer a site from HTTP to HTTPS. If external resources were referred to using http://...
in that case, the browser would block them. Using this technique, it will request the HTTPS version automatically, without any need to modify the code.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install resource-hints
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page