在閱讀HTTP2 Article using Speedy NPM module後,我有一個問題。HTTP2推送腳本標籤在res.end
HTTP2推送的好處是瀏覽器在瀏覽器請求之前緩存資源。
在這個例子中:
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);
是什麼<script src="/main.js"></script>
實際上會導致瀏覽器在res.end('Hello World! <script src="/main.js"></script>')
辦?
如果index.html裏面有<script src="/main.js"></script>
,爲什麼把它放在res.end('Hello World! <script src="/main.js"></script>')
?
我對此也很感興趣。有人問我是否在[此SO問題]中的文檔中添加資源(http://stackoverflow.com/questions/34049872/http2-spdy-push-stream-verification-how-to-test#comment55854460_34049872)。 – CelticParser