Next-plugins: Commons css bundle not cached (served with cache-control: public, max-age=0)

Created on 1 Apr 2019  路  8Comments  路  Source: vercel/next-plugins

Bug report

Describe the bug

Commons css chunk served with cache-control: public, max-age=0 header.

Expected behavior

Expect the bundle to be served immutable, preferably with the same caching header as the js bundle (cache-control: public, max-age=31536000, immutable).

Screenshots

commons-chunk-css

commons-chunk-js

System information

  • OS: macOS 10.14.3
  • Browser: Google Chrome 73.0.3683.86 64-bit
  • Version of Next.js: 8.0.3

Additional context

My next.config.js, not doing anything crazy here. Feel free to check it out live here.

Most helpful comment

Since our nextjs server is behind an nginx reverse proxy anyway I'm now just forcing the Cache-Control header on all static assets.

location ~ \.(?:ico|css|js|gif|jpe?g|png|webp|gif|svg)$ {
  proxy_pass http://next:3000;
  proxy_hide_header Cache-Control;
  add_header Cache-Control "public, max-age=31536000, immutable";
}

All 8 comments

Since our nextjs server is behind an nginx reverse proxy anyway I'm now just forcing the Cache-Control header on all static assets.

location ~ \.(?:ico|css|js|gif|jpe?g|png|webp|gif|svg)$ {
  proxy_pass http://next:3000;
  proxy_hide_header Cache-Control;
  add_header Cache-Control "public, max-age=31536000, immutable";
}

I believe this issue was resolved in PR #335 within the code here on github, however when you install @zeit/next-css via npm or yarn I'm getting a version which still outputs the css to static/css instead of the newly updated static/chunks as per the PR. @timneutkens is there any timeline on when this fix will be pushed to npm? I'm still having this issue and have a massive build that's getting close to production release, so would really love to be able to resolve this :)

I believe this issue was resolved in PR #335 within the code here on github, however when you install @zeit/next-css via npm or yarn I'm getting a version which still outputs the css to static/css instead of the newly updated static/chunks as per the PR. @timneutkens is there any timeline on when this fix will be pushed to npm? I'm still having this issue and have a massive build that's getting close to production release, so would really love to be able to resolve this :)

For some reason all these wonderful fixes have been hiding in the canary channel.
This should install next-css with the necessary fixes: npm install --save @zeit/[email protected]

@charles4221 @wouterds

This bug seems to be back with the built-in CSS support in nextjs with nextjs 9.2

@haf just checked and looks fine:

Screen Shot 2020-02-25 at 13 52 02

Note that if you use @zeit/next-sass / @zeit/next-css built-in support is disabled.

@tim-phillips
image

next@^9.2.0:
  version "9.2.0"
  resolved "https://registry.yarnpkg.com/next/-/next-9.2.0.tgz#1adc85ad45143114cd22e6a68337f56319cd59d2"
  integrity sha512-c4gyJotZHuvq9dslum+Z2Z21jjb9qWMYybV+IS9yEg7hTjs8OyKU59snyJ1Bi0ul84OdyLOZ4ytjch9zMw9lEQ==
  dependencies:
const express = require('express')
const next = require('next')

const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()

app.prepare().then(() => {
  const server = express()
  server.disable('x-powered-by')
  server.all('*', (_, resp, next) => { resp.vary('accept-language'); next() })
  server.all('*', handle)
  server.listen(port, err => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}`)
  })
}).catch(ex => {
  console.error(ex.stack)
  process.exit(1)
})

Also, as you can see, we're removed those packages you mention:

image

You're not on the latest version of Next.js, please upgrade.

Indeed, the last two patch versions seems to have fixed it! Thanks :)

Was this page helpful?
0 / 5 - 0 ratings