koa-addpushheader
v1.0.1
Published
KOA Parser middleware for `this.body`. Finds local URLs and adds them to the `Link` HTTP header. HTTP/2 reverse proxies like nghttpx then push these resources to the client.
Downloads
5
Maintainers
Readme
koa-addpushheader
This middleware (generator function) will parse a response body for any local linked assets (CSS, images, etc) and add them to the response headers. Modern HTTP/2 reverse proxies like nghttpx parse this header and send out the required push promises to the client.
Usage
Use the library like this:
npm install --save koa-addpushheader
app.use(require('koa-addpushheader'));
// view handling code
Notes
The header added to the response looks like this:
link: </apple-icon-57x57.png>; rel=preload, ...
Currently the following file types are added:
bmp
, css
, eot
, gif
, ico
, jpg
, jpeg
, js
, otf
, png
, svg
, ttf
, webm
, webp
, woff
, woff2
For the complete spec on rel=preload
see:
http://w3c.github.io/preload/
License
This project is licensed as LGPLv3, the license file is included in the project directory.
Copyright 2015 Stefan Hamminga - prjct.net