opennextjs / opennextjs-aws

Open-source Next.js adapter for AWS
https://opennext.js.org
MIT License
4.14k stars 126 forks source link

Next Cache never expires with Pages Router #389

Closed SapientMatt closed 1 month ago

SapientMatt commented 8 months ago

Hi,

I'm currently attempting to use ISR, without on demand invalidation, where my pages are supposed to expire after 10 minutes. I can see the cloudfront cache expire and it coming to next, however next never seems to regenerate the page no matter how long I wait. Deleting all files with the _cache/ prefix in the app bucket seems to force this regeneration to occur.

Additionally, there never seem to be any entries added to the dynmaodb table.

On next 13.5.6 and opennext 2.3.5

conico974 commented 8 months ago

Page router don't use dynamodb How are you deploying ? With sst ? What are the X-Nextjs-Cache, Cache-Control and X-Cache headers for your stale pages ? You're not building on windows ?

SapientMatt commented 8 months ago

Yeah deploying via SST.

x-nextjs-cache: STALE Cache-Control: s-maxage=2, stale-while-revalidate=2592000 X-Cache: RefreshHit from cloudfront Age: 92

Have deployed from local built on windows and from pipeline built on ubuntu, both behave similarly.


From: conico974 @.> Sent: Wednesday, 20 March 2024 18:01 To: sst/open-next @.> Cc: Matt Ekron @.>; Author @.> Subject: Re: [sst/open-next] Next Cache never expires with Pages Router (Issue #389)

Page router don't use dynamodb How are you deploying ? With sst ? What are the X-Nextjs-Cache, Cache-Control and X-Cache headers for your stale pages ? You're not building on windows ?

— Reply to this email directly, view it on GitHubhttps://github.com/sst/open-next/issues/389#issuecomment-2009930062, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AVKHFLGF52QUTOZEKOLKIZ3YZGXHDAVCNFSM6AAAAABE7SQ4H2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMBZHEZTAMBWGI. You are receiving this because you authored the thread.Message ID: @.***>

conico974 commented 8 months ago

Try adding x-prerender-revalidate to the list of allowed cache policy headers in cloudfront. There is a PR for that already https://github.com/sst/sst/pull/3713 You can do it in the aws console for testing.

FYI open-next doesn't work on windows https://github.com/sst/open-next/issues/385

If this doesn't solve the issue, you'll need to create a minimum repro

fwang commented 8 months ago

just chiming in. PR is merged. 2.41.3 should have x-prerender-revalidate included in the allowed headers.

conico974 commented 1 month ago

I'm going to close this old issue. If that's still an issue, reopen and provide a reproduction