【发布时间】:2017-09-06 23:19:33
【问题描述】:
我已经制作了一个小型服务器来在节点上尝试 http2,但是我无法判断推送机制是否正常工作。我的样式是通过 http2 加载的,但这并不意味着推送按预期工作......
const port = 3000
const spdy = require('spdy')
const express = require('express')
const path = require('path')
const fs = require('fs')
const app = express()
app.get('*', (req, res) => {
res.set('Link', '</css/styles.css>; rel=preload; as=style');
res.sendFile(__dirname + '/index.html')
})
const options = {
key: fs.readFileSync(__dirname + '/keys/server.key'),
cert: fs.readFileSync(__dirname + '/keys/server.crt')
}
spdy.createServer(options, app).listen(3000);
在开发工具中,发起者说:“其他”。
【问题讨论】:
-
尝试在chrome中使用this,蓝色表示spdy,红色表示http1.1,绿色表示quic
-
@alpheus http2 工作正常,我可以在 devtool 网络协议栏中看到。但是没有提到推送。您的扩展程序中也没有提及它(顺便说一句,它对我来说是蓝色的)。
标签: node.js http express google-chrome-devtools http2