Open ishaqibrahimbot opened 1 year ago
Hi @ishaqibrahimbot 👋 , thanks for reaching out to us!
Just a quick note here, I am working on reproducing this behavior on my end and will keep you posted on the findings.
Thanks!
Hey @Jay2113. did you find anything? 😄
Edit: Have some more information for you. I created a new Amplify project in another AWS account. Here's what I found that was consistent across both of my Amplify projects:
pages/category/[slug].tsx
, pages/product/[slug].tsx
, pages/blog/[slug].tsx
. The caching behavior, although I noticed it, is pretty random and short-lived. A page gets cached after refreshing several times, then on the very next refetch it goes back to fallback despite an s-maxage: 43200
header being present on the cache hit version.Examples of this:
pages/[...path].tsx
just doesn't seem to be getting cached at all, no matter how many times I refresh/refetch.Example:
getStaticPaths
and fallback: false
for the pages/[...path].tsx
route. The build logs report that all those paths were generated successfully. However, I get a 404 whenever I visit any of those pages.Maybe this helps you debug the issue better? 🙂
Hey @Jay2113! Is there any update about this? My project is really close to launch so I would really like to solve this issue. Thanks 🙂
I ran a preview build with a set of paths in getStaticPaths and fallback: false for the pages/[...path].tsx route. The build logs report that all those paths were generated successfully. However, I get a 404 whenever I visit any of those pages.
I am seeing same behavior where logs show pages being prebuilt but they show as 404
next version:
➜ cat package.json | grep '"next"'
"next": "13.4.10",
Any progress on this or known workarounds?
Any progress on this or known workarounds?
@alex-anikeev We figured out that the issue was with ISR. If your use case can bear it, I would suggest not using ISR for your dynamic routes. We started getting correct cache hits from the nextjs server when we did that.
Before opening, please confirm:
App Id
ds9myrwx73uix
AWS Region
ap-southeast-2
Amplify Hosting feature
Deployments, Frontend builds, SSR
Describe the bug
I have a Nextjs v12.2 app deployed on Amplify with the
WEB_COMPUTE
platform. As part of this, I have some dynamic routes for which I am statically generating some paths usinggetStaticPaths
.In the Frontend build logs, these paths show up as successfully generated. However, when I try to access those paths, I get the fallback mode and it takes a while for the actual page data to come through. So basically these paths weren't really cached.
Expected behavior
Paths that are statically generated at build time should be served from the Nextjs cache and I should get the rendered HTML on the first request instead of getting the fallback mode.
Reproduction steps
Not sure how to describe reproduction, but here's how I get the bug:
pages/[...path].tsx
getStaticPaths
function and return some valid paths from itBuild Settings
No response
Log output
Additional information
I've checked the headers on a lot of pages including non-dynamic ones such as the homepage of my app, and it looks like none of these are hitting the nextjs cache either. I'm getting a constant
MISS
for thex-nextjs-cache
header. The non-dynamic ones are instead coming from Cloudfront's cache.