Skip to content

Proposal: Expose initiator to JavaScript #1430

Open
@d3lm

Description

@d3lm

The specification talks about the initiator but it's not exposed to JavaScript. At StackBlitz we have a concrete use case for WebContainer to run Node.js natively in the browser. More specifically, when intercepting fetch requests in a service worker, it would be very ideal to access the initiator because we need to implement a custom cache layer (e.g. prefetch cache) inside the service worker. In our use case, requests to localhost will never reach the browser's native network layer and are sent to the Node process (the server) running in another tab. To be able to implement e.g. the prefetch cache we'd have to know whether the request was initiated by rel=prefetch.

My naive suggestion would be to expose the initiator property on the request object.

interface Response {
  initiator: 'download' | 'imageset' | 'manifest' | 'prefetch' | 'prerender' | 'xslt' | ''
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions