#Why next js is build my dynamic pages as static?

10 messages · Page 1 of 1 (latest)

midnight tartan
#

I have a page when I want to render list of items that come form DB. This list frequently changes so I need to get fresh request every time I access the page. The page is async and I fetch data server side. I am using app router and next js 14.

export default async function Page() { const { data, total_count } = await getItems(); return .. }

Why next js is building this page as static and even when I add new items to db the list remains the same? Should not the be dynamicaly fetched every at each request?

hybrid pagodaBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

lone nebula
#

Next.js cache fetch by default

I really don’t like this behavior. Fortunately, this will change in Next.js 15.

thin swallow
midnight tartan
#

@thin swallow @lone nebula I have managed to fix that by adding no-store option to fetch request OR by setting revalidate = 0. How does it differ then? Is revalidate reffering to the next cache whereas fetch no-store to the fetch/react wrapper cache?

thin swallow
#

depending on the use case, one might be better than the other, or the two might have the same behaviour

midnight tartan
#

@thin swallow that makes sense, thank you for clarifying

#

astly how export const dynamic = "force-dynamic" differs to the methods mentioned above? Docs say that it also turns the page into dynamically rendered at request time?

thin swallow
# midnight tartan astly how export const dynamic = "force-dynamic" differs to the methods mentione...

force-dynamic is slightly worse than revalidate=0 because it forces everything to be dynamic. so even if you have a query in the page that you explicitly configure it to be static, that force-dynamic will still override it.

it's sort of like this:

for a particular query, is there an explicit static/dynamic configuration?

if yes, it remains as configured if revalidate=0 is used, while it will become dynamic if force-dynamic is used.

if no, both revalidate=0 and force-dynamic have the same behaviour.