Skip to content

Fetch settings attribute? #21

Closed
Closed

Description

@yoavweiss

I was looking at the slide deck overviewing resource hints (which is awesome, BTW), and saw the fetch-settings header.

It made me wonder:

  • The value of that attribute seems to be JSON based. Are there any precedents to JSON being used as an attribute value?
  • Do we know of other values that need to be passed as fetch settings other than destinationContext?
  • The attribute name has a dash in it, which is mainly used in data attributes. I may be wrong, but some people may have strong opinions against that.

Activity

  1. igrigorik commented on Aug 21, 2014

    @igrigorik
    Owner

    The value of that attribute seems to be JSON based. Are there any precedents to JSON being used as an attribute value?

    The paint is fresh on this one. The idea is to pass that as an initialization hash to Fetch.. see:

    Do we know of other values that need to be passed as fetch settings other than destinationContext?

    For background: #6 (comment). In terms of other attributes, custom HTTP headers, and other Fetch request initialization options.

    The attribute name has a dash in it, which is mainly used in data attributes. I may be wrong, but some people may have strong opinions against that.

    Not attached to it. Just going by what's being discussed in the linked bug above.

  2. yoavweiss commented on Aug 22, 2014

    @yoavweiss
    ContributorAuthor

    The use of JSON scares me from an implementation point of view.
    Since this is a mechanism for talking to the preloader, and the preloader is implemented off-main-thread in at least Gecko and Blink (not sure about IE), it probably has no access to existing JSON parsers. I also don't think either of them uses the Fetch object underneath.

    I didn't study this in detail for Blink, but I suspect that using JSON would require creating a thread-safe JSON parser, which will likely complicate implementation.

    So, if we have alternatives to using JSON here, they may be better for quick adoption.

  3. igrigorik commented on Aug 22, 2014

    @igrigorik
    Owner

    That's good feedback - thanks.

    At the moment the primary thing we need to communicate is destinationContext, so we could pull it out into a separate attribute. However, thinking a bit ahead, it does seem like there would be cases where you'd want to (declaratively) specify some extra request headers, override default request priorities, and so on. Exposing attributes for all of those would be a painful exercise... on the other hand, a JSON hash is something that can be easily extended in the future.

  4. yoavweiss commented on Aug 22, 2014

    @yoavweiss
    ContributorAuthor

    It might be worth while to get @abarth's opinion on this, but I think it'd be a good idea to split the destinationContext to a separate attribute, so that an initial implementation will be relatively simple, and add the extra complexity of a JSON based attribute later on, if neccessary.

  5. igrigorik commented on Aug 22, 2014

    @igrigorik
    Owner

    Updated the spec to use fetch-settings in 955a9ff. See here:
    https://igrigorik.github.io/resource-hints/#fetch-settings

    Let's see what the feedback is... It's easy enough to change it back to a dedicated attribute and then expose the JSON variant later once Fetch is further along.

  6. bizzbyster commented on Aug 25, 2014

    @bizzbyster

    "It's easy enough to change it back to a dedicated attribute and then expose the JSON variant later once Fetch is further along."

    +1.

    It seems like you are anticipating a need that we may not have here. It may be that destinationContext alone will be needed.

  7. bizzbyster commented on Aug 26, 2014

    @bizzbyster

    @igrigorik Would the destinationContext value be set as the initiatorType for this fetched resource in the Resource Timing API?

    If so, this would close the loop on the issue discussed here: http://lists.w3.org/Archives/Public/public-web-perf/2014Aug/0013.html.

  8. igrigorik commented on Aug 27, 2014

    @igrigorik
    Owner

    @bizzbyster no, initiatorType should be left as is. We need to know who initiated the fetch - see #19. That said, as doc'ed in that bug, there is a chance we'll need a new attribute to expose if the resource was matched against a speculative fetch.

  9. bizzbyster commented on Aug 28, 2014

    @bizzbyster

    Ilya,

    The system I am building is using Resource Timing API feedback to auto-generate preload resource hints. I therefore need some way to get the destinationContext value (Script, Image, etc.) from the Resource Timing API. If not initiatorType, what do you suggest?

    Thanks,

    Peter

  10. igrigorik commented on Aug 28, 2014

    @igrigorik
    Owner

    @bizzbyster I'm suggesting that we need a new attribute on NavTiming/ResourceTiming to expose this data - see #19 and lets continue that discussion there.

  11. bizzbyster commented on Aug 29, 2014

    @bizzbyster

    Sounds good okay. That other thread just seemed more about indicating if a hint was "used" or not. As opposed to making sure we're able to get the initiatorType and destinationContext in the RT/NT API.

  12. igrigorik commented on Aug 30, 2014

    @igrigorik
    Owner

    @yoavweiss think as should address all of the above.. and much cleaner too! Let me know if otherwise.

  13. yoavweiss commented on Aug 31, 2014

    @yoavweiss
    ContributorAuthor

    LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions