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?










share|improve this question






















  • 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















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?










share|improve this question






















  • 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













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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini