After reading HTTP2 Article using Speedy NPM module, I have a question.
The benefit of HTTP2 push is that the browser has the resources cached before the browser requests them.
In this example:
spdy.createServer(options, function(req, res) {
// push JavaScript asset (/main.js) to the client
res.push('/main.js', {'content-type': 'application/javascript'}, function(err, stream) {
stream.end('alert("hello from push stream!")');
});
// write main response body and terminate stream
res.end('Hello World! <script src="/main.js"></script>');
}).listen(443);
What does <script src="/main.js"></script>
actually cause the browser to do in res.end('Hello World! <script src="/main.js"></script>')
?
And if the index.html has <script src="/main.js"></script>
inside of it, why place it in res.end('Hello World! <script src="/main.js"></script>')
?