mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-19 23:21:09 +00:00
feat(http2): add render.http2.push option
This option disables http2 push headers by default as is currently inconsistent with different browser and webservers
This commit is contained in:
parent
5763d21905
commit
349f6e6219
@ -51,6 +51,9 @@ class Nuxt {
|
||||
scrollBehavior: null
|
||||
},
|
||||
render: {
|
||||
http2: {
|
||||
push: false
|
||||
},
|
||||
static: {},
|
||||
gzip: {
|
||||
threshold: 0
|
||||
|
@ -74,8 +74,8 @@ export async function render (req, res) {
|
||||
}
|
||||
res.setHeader('ETag', etag)
|
||||
}
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8')
|
||||
res.setHeader('Content-Length', Buffer.byteLength(html))
|
||||
// HTTP2 push headers
|
||||
if(!error && this.options.render.http2.push) {
|
||||
// Parse resourceHints to extract HTTP.2 prefetch/push headers
|
||||
// https://w3c.github.io/preload/#server-push-http-2
|
||||
const regex = /link rel="([^"]*)" href="([^"]*)" as="([^"]*)"/g
|
||||
@ -88,6 +88,9 @@ export async function render (req, res) {
|
||||
}
|
||||
}
|
||||
res.setHeader('Link', pushAssets)
|
||||
}
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8')
|
||||
res.setHeader('Content-Length', Buffer.byteLength(html))
|
||||
res.end(html, 'utf8')
|
||||
return html
|
||||
} catch (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user