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

CloudFront caching errors #2355

Closed
4 tasks done
marco910 opened this issue Oct 29, 2021 · 3 comments
Closed
4 tasks done

CloudFront caching errors #2355

marco910 opened this issue Oct 29, 2021 · 3 comments
Labels
archived This issue has been locked. question Further information is requested ssr Server Side Rendering feature

Comments

@marco910
Copy link

Before opening, please confirm:

App Id

d7rx5b5im0en3

Region

eu-central-1

Amplify Console feature

Not applicable

Describe the bug

I'm using Next.js with Incremental Site Regeneration (ISR) on Amplify. I noticed that when accessing a page that isn't built yet I'm getting a 404 error and this error is cached by CloudFront with the Cache-Control header public, max-age=0, s-maxage=2678400, must-revalidate.

I also tried overriding this Cache-Control headers, but that didn't work.

Expected behavior

CloudFront shouldn't cache 404 or any other errors.

Reproduction steps

  1. Deploy a Next.js app with ISR on Amplify.
  2. Try to access an ISR route – like "/news/awesome-post" that isn't built but is already created in the CMS.
  3. Check the headers in the dev tools of your browser.

Build Settings

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - yarn install
    build:
      commands:
        - yarn run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Additional information

customHTTP.yml:

customHeaders:
  - pattern: '**/*'
    headers:
      - key: Cache-Control
        value: 'public, max-age=0, s-maxage=0, no-cache'
      - key: x-frame-options
        value: DENY
      - key: x-xss-protection
        value: 1; mode=block
@ghost ghost added question Further information is requested ssr Server Side Rendering feature labels Oct 29, 2021
@calavera
Copy link
Contributor

Hi,

CloudFront doesn't cache errors anymore. We also just announced several improvements to our cache handling.

Check out the details here: https://aws.amazon.com/blogs/mobile/cdn-caching-improvements-for-better-app-performance-with-aws-amplify-hosting/

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 ssr Server Side Rendering feature
Projects
None yet
Development

No branches or pull requests

2 participants