Tuesday, 11 April 2017

Express http 2 server push

I've made a small server to try http2 on node, however I can't tell if the push mechanism is working or not. My style is loaded over http2 but that does not mean that push is working as intended...

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);

In the devtools, the initiator says : "other".



via Ced

No comments:

Post a Comment