koa-server-push
HTTP2 Server Push middleware for Koa
Installation
$ npm install koa-server-push
API
Usage for Koa 2.x (current version of node)
const Koa = ;const serverpush = ;const app = ; app;// OR// app.use(serverpush({// manifestName: 'anothername.json',// gaeproxy: true,// singleheader: true// }));
Options (optional)
manifestName
The name of the manifest files. Defaults to'push_manifest.json'
.gaeproxy
Set theX-Associated-Content
header as well. Defaults tofalse
.singleheader
Set theLink
header as a comma separated string instead of multipleLink
headers. Defaults tofalse
.
Example
'use strict'; const Koa = ;const serve = ;const convert = ;const serverpush = ; const app = ; app;// OR// app.use(serverpush({// manifestName: 'anothername.json',// gaeproxy: true,// singleheader: true// }));app; /** * Note: * Please ensure that the server push middleware is not used after the * middleware that sets the response body and response type. This use case is * not supported at this time. */ app;