igrigorik / http-client-hints

402 stars 24 forks source link

How to know at navigational request whether the client will send client hints for referenced image? #54

Closed waldbaerkoch closed 8 years ago

waldbaerkoch commented 9 years ago

About a year ago, I opened issue #27, which was closed. Now that there are client hints in Chrome 46, I still have the same question. The examples in section '<picture> element' seem to make the assumption that longer markup with srcset can be reduced server-side to shorter markup, e.g.

<!-- viewport-based selection -->
<img src="wolf-400.jpg" sizes="100vw" alt="The rad wolf"
     srcset="wolf-400.jpg 400w, wolf-800.jpg 800w, wolf-1600.jpg 1600w">

<!-- equivalent functionality with DPR and Width hints -->
<img src="wolf.jpg" sizes="100vw" alt="The rad wolf">

But currently, I cannot expect every browser to send client hints. So I have to decide (per request?) when to send the longer or the shorter version in the response to a navigational request. So I need some information in the navigational request as well. Currently, Chrome 46 does not send client hints in a navigational request. If it did send e.g. DPR, I would add

Vary: DPR

to the response. But that would result in too many cache entries for the same URI in intermediary caches (one version for each DPR header value). One version for present DPR header (shorter markup) and another for missing DPR header (longer markup) would be sufficient. So what do you think is a good way to handle this?

igrigorik commented 9 years ago

The first iteration of CH, at least as we're shipping in Chrome, does not address the "hints on navigational request" use case. This is intentional on our part: there are legitimate concerns over sending a lot of new headers to sites that won't or don't use them, and there are some potential privacy implications that we'd need to address. As such, the "v1 workflow" is: document request does not get CH; the document response can opt-in to CH; the UA will send CH hints to all subresources of that document. There is no persistence for this preference either, so the same workflow repeats on each visit.

That said, once we have some real-world experience with CH (and once we have some real-world adoption + usefulness data), I do plan to take a second run at the navigational use-case... Which will likely be based on some persistence model where the navigational case is addressed on repeat navigations - see https://github.com/igrigorik/http-client-hints/pull/34.

igrigorik commented 8 years ago

Closing. If you want to reopen, please do so on: https://github.com/httpwg/http-extensions/issues?q=is%3Aopen+is%3Aissue+label%3Aclient-hints

paulirish commented 6 years ago

I seem to remember there've been more recent discussions on the navigational request usecase, perhaps pointing to a solution. But I can't find anything in here or the http-extensions repo. Perhaps I was imagining that?


Commenting in this deprecated repo in case other people are searching for the same answer. ;)

igrigorik commented 6 years ago

@paulirish great timing! We just landed Accept-CH-Lifetime in Canary today, which enables delivery of hints on navigation requests: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/8RBFue7RMXQ