Skip to content

nextjs static assets added to response header so proxy can http2 push them

Notifications You must be signed in to change notification settings

littletelx360/next-preload-headers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

next-preload-headers

npm version

express middleware that adds preload tags in body of initial response into header where proxy will generally upgrade them to http2 server push. Server pushing critical assets improves response time, especially for mobile users.

Usage

npm install --save next-preload-headers

Add it to the express server.js like this:

const nextPreloadHeaders = require('next-preload-headers')

const app = express()

app.use(nextPreloadHeaders)

TODO:

  • add css to the top of the list since it is generally the most important
  • send/check a cookie with buildId so we know if resources need to be pushed for this build
  • consider sorting style elements first
  • figure out why sometimes getting "can't add headers to already sent response". I think this is just an HMR issue in dev.

##Changelog:

  • 3.0.4 - adding stylesheet link tags
  • 3.0.3 - fix error with semicolon separating links when should have been comma

About

nextjs static assets added to response header so proxy can http2 push them

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%