Use HTTP preload with EventSource/Server Sent Events?
up vote
3
down vote
favorite
I have a page that immediately starts streaming events upon load, via an EventSource. To speed up the start of that stream, I'd like to use HTTP preload meta tags. But when I add this to my page:
<link rel="preload" as="fetch" crossorigin="crossorigin" href="http://myeventsource" />
Chrome warns me:
A preload for 'http://myeventsource' is found, but is not used because the request headers do not match.
Which is true: the preload has an Accept
header of */*
, while the EventSource-originated request has an Accept
header of text/event-stream
. The reading I've been doing suggests that the content of that header is controlled by the as
parameter in the meta tag, but as far as I can see there is no eventstream-specific value.
Is there any way for me to override the Accept
header it's sending?
javascript http http-headers eventsource
add a comment |
up vote
3
down vote
favorite
I have a page that immediately starts streaming events upon load, via an EventSource. To speed up the start of that stream, I'd like to use HTTP preload meta tags. But when I add this to my page:
<link rel="preload" as="fetch" crossorigin="crossorigin" href="http://myeventsource" />
Chrome warns me:
A preload for 'http://myeventsource' is found, but is not used because the request headers do not match.
Which is true: the preload has an Accept
header of */*
, while the EventSource-originated request has an Accept
header of text/event-stream
. The reading I've been doing suggests that the content of that header is controlled by the as
parameter in the meta tag, but as far as I can see there is no eventstream-specific value.
Is there any way for me to override the Accept
header it's sending?
javascript http http-headers eventsource
did you make any progress on this?
– skzryzg
2 days ago
No, as best I can tell it isn't possible right now. An alternative is HTTP2 push, I haven't investigated it too much but it might be worth a look.
– Alastair
2 days ago
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a page that immediately starts streaming events upon load, via an EventSource. To speed up the start of that stream, I'd like to use HTTP preload meta tags. But when I add this to my page:
<link rel="preload" as="fetch" crossorigin="crossorigin" href="http://myeventsource" />
Chrome warns me:
A preload for 'http://myeventsource' is found, but is not used because the request headers do not match.
Which is true: the preload has an Accept
header of */*
, while the EventSource-originated request has an Accept
header of text/event-stream
. The reading I've been doing suggests that the content of that header is controlled by the as
parameter in the meta tag, but as far as I can see there is no eventstream-specific value.
Is there any way for me to override the Accept
header it's sending?
javascript http http-headers eventsource
I have a page that immediately starts streaming events upon load, via an EventSource. To speed up the start of that stream, I'd like to use HTTP preload meta tags. But when I add this to my page:
<link rel="preload" as="fetch" crossorigin="crossorigin" href="http://myeventsource" />
Chrome warns me:
A preload for 'http://myeventsource' is found, but is not used because the request headers do not match.
Which is true: the preload has an Accept
header of */*
, while the EventSource-originated request has an Accept
header of text/event-stream
. The reading I've been doing suggests that the content of that header is controlled by the as
parameter in the meta tag, but as far as I can see there is no eventstream-specific value.
Is there any way for me to override the Accept
header it's sending?
javascript http http-headers eventsource
javascript http http-headers eventsource
asked Nov 8 at 18:43
Alastair
3,13052246
3,13052246
did you make any progress on this?
– skzryzg
2 days ago
No, as best I can tell it isn't possible right now. An alternative is HTTP2 push, I haven't investigated it too much but it might be worth a look.
– Alastair
2 days ago
add a comment |
did you make any progress on this?
– skzryzg
2 days ago
No, as best I can tell it isn't possible right now. An alternative is HTTP2 push, I haven't investigated it too much but it might be worth a look.
– Alastair
2 days ago
did you make any progress on this?
– skzryzg
2 days ago
did you make any progress on this?
– skzryzg
2 days ago
No, as best I can tell it isn't possible right now. An alternative is HTTP2 push, I haven't investigated it too much but it might be worth a look.
– Alastair
2 days ago
No, as best I can tell it isn't possible right now. An alternative is HTTP2 push, I haven't investigated it too much but it might be worth a look.
– Alastair
2 days ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53214208%2fuse-http-preload-with-eventsource-server-sent-events%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
did you make any progress on this?
– skzryzg
2 days ago
No, as best I can tell it isn't possible right now. An alternative is HTTP2 push, I haven't investigated it too much but it might be worth a look.
– Alastair
2 days ago