Skip to content

Stale politician data after browser back navigation #153

Description

@monneyboi

Bug

After adding a source to a politician, navigating to the stats page, then pressing the browser back button, the newly added source is not visible. A full page refresh is required to see it.

Root Cause

The politician page (src/app/(app)/politician/[qid]/page.tsx) is a server component that fetches data via fetchWithAuth() without specifying cache: 'no-store'. In Next.js 16, server-side fetch() defaults to caching the response.

When a source is added, refetchPolitician() in PoliticianEvaluation.tsx updates client-side React state, but does not invalidate the Next.js server component cache. On back navigation, Next.js restores the page from its stale server cache rather than re-fetching.

Steps to Reproduce

  1. Visit a politician page
  2. Add a source
  3. Navigate to the stats page
  4. Press browser back button
  5. Observe the source is missing — refresh to see it

Suggested Fix

Add cache: 'no-store' to the fetch call in page.tsx, or use revalidatePath()/revalidateTag() after mutations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    guiGUI/interface related issues

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions