Next.js Discord

Discord Forum

Server keeps around stale data from DB

Unanswered
Selkirk Rex posted this in #help-forum
Open in Discord
Selkirk RexOP
I have some pretty simple code to fetch data from the DB:

export const fetchCache = 'force-no-store';
export const dynamic = 'force-dynamic';
export const revalidate = 0;

export default async function UserPage(props)
{
    const { username } = props.params;
    const userData = await AppPrismaClient.user.findFirst({
        where: {
            name: username
        }
    });

    return (
        <>
            {userData.bio}
        </>
    )
}


However, when this data changes, and the page is navigated to (without refreshing), it keeps around the stale data, despite the three lines at the top of the code. Am I missing something? I assumed that every time you navigate to the page, it'd fetch data from the server.

4 Replies

Selkirk RexOP
Is forcing a page refresh the only way to update the data?
You just found the thing most people hate about Next.js caching
Selkirk RexOP
well, that doesn't sound good lol