feat(http2): push assets with single link header

less payload!

https://blog.cloudflare.com/http-2-server-push-with-multiple-assets-per-link-header
This commit is contained in:
Pooya Parsa 2017-06-05 13:26:07 +04:30
parent 0468c7997e
commit bd54ddd2a7

View File

@ -87,7 +87,9 @@ export async function render (req, res) {
pushAssets.push(`<${href}>; rel=${rel}; as=${as}`) pushAssets.push(`<${href}>; rel=${rel}; as=${as}`)
} }
} }
res.setHeader('Link', pushAssets) // Pass with single Link header
// https://blog.cloudflare.com/http-2-server-push-with-multiple-assets-per-link-header
res.setHeader('Link', pushAssets.join(','))
} }
res.setHeader('Content-Type', 'text/html; charset=utf-8') res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.setHeader('Content-Length', Buffer.byteLength(html)) res.setHeader('Content-Length', Buffer.byteLength(html))