#force-dynamic not working

1 messages · Page 1 of 1 (latest)

frail dagger
#

i have page

import TicketContainer from '@/components/Support/Ticket/TicketContainer'

import { GetTicketById } from '@/system/backend/support'
import { cookies, headers } from 'next/headers'
import { API_URL } from '@/system/constants'
import { notFound } from 'next/navigation'

export const dynamic = 'force-dynamic'
export const revalidate = 0

export default async function TicketPage({ params }: { params: Record<string, string> }) {
headers()
const res = await fetch(API_URL + GetTicketById + '?id=' + params.ticket_id, {
headers: { Authorization: cookies().get('tokenid')?.value || '' },
cache: 'no-store',
}).then((r) => r.json())

console.log(res.data.ticket.status)

if (res.status_code !== 200) return notFound()

return (
    <>
        <div className="flex w-full flex-col">
            <TicketContainer data={res.data.ticket} />
        </div>
    </>
)

}

there is force-dynamic and even cache no store, but page is still caching this request when im openning this page with <Link> component.this request should run on every request

leaden sluiceBOT
#

Hi @frail dagger. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Based on the information provided in the extracts, it seems that there are some issues with the force-dynamic setting in Next.js not being respected in certain scenarios. This issue has been reported by multiple users on GitHub (source (https://github.com/vercel/next.js/issues/52350), source (https://github.com/vercel/next.js/issues/47148), source (https://github.com/vercel/next.js/issues/55042)).

One workaround suggested by a user is to call a dynamic function on top of the server action. Here's the example provided:

// ./_actions/get-time.ts
"use server";

import { headers } from "next/headers";

export async function getTime() {
// Temp workaround to force all fetch calls inside this function to not cache their results
headers()
  
...
}

(source (https://github.com/vercel/next.js/issues/52350))

However, please note that this is a workaround and may not work in all scenarios. It's recommended to keep an eye on the GitHub issues for any updates or fixes from the Next.js team.

If you're still facing issues, you might want to consider opening a new issue on the Next.js GitHub repository with a detailed description of your problem and the code you're using. This could help the Next.js team identify and fix the issue.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@frail dagger kapa.ai is still learning and improving, please let us know how it did by reacting below

frail dagger
#

as you can see in my code its just page not server actions and im using headers() on top

#

as you can see in my code its just page not server actions and im using headers() on top @leaden sluice

leaden sluiceBOT
#

Let me check the knowledge base for you. One moment! :books:

#

I see that you're already using headers() at the top of your function, which is similar to the workaround suggested in the GitHub issue. However, it seems that this workaround might not be effective in all scenarios.

The issue you're facing seems to be a known problem with Next.js where the force-dynamic setting is not always respected. This has been reported in multiple GitHub issues (source (https://github.com/vercel/next.js/issues/52350), source (https://github.com/vercel/next.js/issues/47148), source (https://github.com/vercel/next.js/issues/55042)).

Unfortunately, based on the information provided in the extracts, there doesn't seem to be a definitive solution to this problem yet. The Next.js team is likely aware of this issue and working on a fix.

In the meantime, you might want to consider opening a new issue on the Next.js GitHub repository with a detailed description of your problem and the code you're using. This could help the Next.js team identify and fix the issue.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: