amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.55k stars 232 forks source link

Caching doesn't work correctly with latest rc #575

Closed max-frai closed 1 year ago

max-frai commented 1 year ago

Description

You have on landing page link to example which uses "latest" tag in package.json and everything is okay. When I migrate app to 3.0.0-rc.6 there is a problem with correct caching headers. With example from landing on production build I see the following headers:

Cache-Control: s-maxage=31536000, stale-while-revalidate

But with rc6 header is:

Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate

Of course, this makes app very slow because nextjs doesn't cache ssr, etc and recalculates everything on each request.

I build a small example with rc6 which after yarn run build and yarn start on main page gives this wrong cache-control header.

Mandatory reproduction URL (CodeSandbox or GitHub repository)

https://github.com/max-frai/nextintl-cache-problem

Reproduction description

Steps to reproduce:

  1. yarn
  2. yarn run build
  3. yarn run start
  4. Open localhost:3000/en
  5. Watch Cache-Control header

Expected behaviour

With production build and all default values for caching it should return the following header: Cache-Control: s-maxage=31536000, stale-while-revalidate

amannn commented 1 year ago

I think you're looking for this: https://next-intl-docs-git-feat-next-13-rsc-next-intl.vercel.app/docs/getting-started/app-router#static-rendering

I'll move this to a discussion, since this appears to be a usage question.