invalidation not working properly for the home page
Unanswered
West African Lion posted this in #help-forum
West African LionOP
Hello, I created a small careers website using Next.js 15.3, Most of the pages are statically generated, and the site also supports a mix of SSG/ISR with revalidation and dynamic routes for the API (build summary image attached).
The site is hosted on AWS S3, and for caching, we use CloudFront.
After every fresh build, I also trigger an AWS CloudFront invalidation task for the following paths: "/" "/index.html" "/_next/" "/career/"
but still even with validation when caching is turned on my site home page fail and i get this long error:
f:"$Sreact.fragment"
10:I[4080,["173","static/chunks/173-5ce2d7c33ed5c6a6.js","576","static/chunks/576-cb1d0e388ff760a8.js,"931","static/chunks/app/page-c648446ee793a58b.js"],""]
11:I[9294,["231","static/chunks/231-bf6075b385130880.js","PageHeader"]
14:I[8173,["173","static/chunks/173-5ce2d7c33ed5c6a6.js","576","static/chunks/576-cb1d0e388ff760a8.js","641","static/chunks/641-37e5b75fcc7eb243.js","931","static/chunks/app/page-c648446ee793a58b.js"],"Image"]
15:I[231,["173","static/chunks/173-5ce2d7c33ed5c6a6.js","231","static/chunks/231-bf6075b385130880.js"],"PageFooter"]
18:I[3120,[],"OutletBoundary"]
1a:I[3120,[],"MetadataBoundary"]
1c:I[3120,[],"ViewportBoundary"]
1:HL["/_next/static/media/1cf13853095a62e2-s.p.woff2","font",
e:HL["/_next/static/css/cb51b40f53a97d6a.css","style"]...
Long story short, the error occurs because when a new build is done, Next.js generates hashed filenames for its JavaScript, CSS, and other assets. For some reason, the invalidation doesn't take effect on the home page of my site, it's like the CDN continues caching the old hashed filenames and keeps referencing them or something. Then, the error appears.
After the error occurs, if I manually perform an invalidation for my domain with the /* path, the site comes back online and works fine.
The backend team says the CloudFront configuration is correct, and they think something is wrong with how the site is generated. Any ideas on what to check?
The site is hosted on AWS S3, and for caching, we use CloudFront.
After every fresh build, I also trigger an AWS CloudFront invalidation task for the following paths: "/" "/index.html" "/_next/" "/career/"
but still even with validation when caching is turned on my site home page fail and i get this long error:
f:"$Sreact.fragment"
10:I[4080,["173","static/chunks/173-5ce2d7c33ed5c6a6.js","576","static/chunks/576-cb1d0e388ff760a8.js,"931","static/chunks/app/page-c648446ee793a58b.js"],""]
11:I[9294,["231","static/chunks/231-bf6075b385130880.js","PageHeader"]
14:I[8173,["173","static/chunks/173-5ce2d7c33ed5c6a6.js","576","static/chunks/576-cb1d0e388ff760a8.js","641","static/chunks/641-37e5b75fcc7eb243.js","931","static/chunks/app/page-c648446ee793a58b.js"],"Image"]
15:I[231,["173","static/chunks/173-5ce2d7c33ed5c6a6.js","231","static/chunks/231-bf6075b385130880.js"],"PageFooter"]
18:I[3120,[],"OutletBoundary"]
1a:I[3120,[],"MetadataBoundary"]
1c:I[3120,[],"ViewportBoundary"]
1:HL["/_next/static/media/1cf13853095a62e2-s.p.woff2","font",
e:HL["/_next/static/css/cb51b40f53a97d6a.css","style"]...
Long story short, the error occurs because when a new build is done, Next.js generates hashed filenames for its JavaScript, CSS, and other assets. For some reason, the invalidation doesn't take effect on the home page of my site, it's like the CDN continues caching the old hashed filenames and keeps referencing them or something. Then, the error appears.
After the error occurs, if I manually perform an invalidation for my domain with the /* path, the site comes back online and works fine.
The backend team says the CloudFront configuration is correct, and they think something is wrong with how the site is generated. Any ideas on what to check?
2 Replies
Yacare Caiman
Hey, apologies, not able to contribute.
Just wanted to check how did you deploy it on aws s3, cloudfront? I am trying the same setup but, making isr work is a nightmare. Thanks
Just wanted to check how did you deploy it on aws s3, cloudfront? I am trying the same setup but, making isr work is a nightmare. Thanks
@Yacare Caiman Hey, apologies, not able to contribute.
Just wanted to check how did you deploy it on aws s3, cloudfront? I am trying the same setup but, making isr work is a nightmare. Thanks
You should open a new #help-forum thread for it.
Next thing, I don't think you can setup ISR when deploying to aws s3.
I recommend using [OpenNext](https://opennext.js.org/aws) to deploy to AWS Lambda
Next thing, I don't think you can setup ISR when deploying to aws s3.
I recommend using [OpenNext](https://opennext.js.org/aws) to deploy to AWS Lambda