Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js API routes are cached by cloudfront #3689

Closed
4 tasks done
markus-mw opened this issue Sep 6, 2023 · 4 comments
Closed
4 tasks done

Next.js API routes are cached by cloudfront #3689

markus-mw opened this issue Sep 6, 2023 · 4 comments
Labels
archived This issue has been locked. question Further information is requested

Comments

@markus-mw
Copy link

Before opening, please confirm:

App Id

d3jneonuggifo0

AWS Region

eu-central-1

Amplify Hosting feature

Custom headers, Public APIs, SSR

Question

Hi all!

I recognized that requests to an Next.js API route are cached for 2 seconds. In between I get an X-Cache Header "Hit from cloudfront". Is there a way to change this behaviour?
In my local environment, I cannot reproduce this behavior. There I always get a freshly generated response.

Thank you
Markus

@markus-mw markus-mw added the question Further information is requested label Sep 6, 2023
@arturkasperek
Copy link

arturkasperek commented Oct 25, 2023

I have the same problem - why it happens?
I was testing locally and nextJS returns cache-control: private, no-cache, no-store, max-age=0, must-revalidate - why CloudFront ignores that?
My app is IP sensitive and with that behavior, some clients receive content that they shouldn't see ...

@calavera
Copy link
Contributor

Hi,

This problem has been resolved. CloudFront doesn't cache for 2 seconds anymore, and it will respect the cache-control response header that your api returns.

I'm closing this issue as it's been resolved.

Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Copy link

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Aug 13, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants