Skip to content

Explicitly avoid items page cache#472

Open
sarangj wants to merge 1 commit intoqafrom
mess_with_cache
Open

Explicitly avoid items page cache#472
sarangj wants to merge 1 commit intoqafrom
mess_with_cache

Conversation

@sarangj
Copy link
Copy Markdown
Contributor

@sarangj sarangj commented Sep 29, 2025

Currently, we use revalidatePath to wipe the cache from the items page

  • reading a bite more, it seems like a simpler approach would be to just not cache the data used to load the items page, and then avoid calling revalidate. In practice, the items endpoint is already not cached anyway, since nextJS has some underlying magic to not cache any of the data if 'dynamic' functions like headers() are called (we call this method to fetch the client side IP address).

In practice, this should do nothing, except maybe reduce a tiny bit of overhead in calling revalidatePath. I think this might just make some of the cache behavior a bit clearer. Additionally, I think the purpose of revalidatePath is to call it when data is mutated, ie, if you have a form submission or button that triggers data updates, and you want to wipe the cache so that the next GET isn't stale. Since DC is read-only, seems like we can avoid that step.

If this looks okay on QA, I may reevaluate our other uses of revalidatePath as well.

Ticket:

This PR does the following:

Open questions

How has this been tested? How should a reviewer test this?

Accessibility concerns or updates

Checklist:

  • I have added relevant accessibility documentation for this pull request.
  • All new and existing tests passed.
  • I have updated the CHANGELOG.md.

Currently, we use `revalidatePath` to wipe the cache from the items page
- reading a bite more, it seems like a simpler approach would be to just
not cache the data used to load the items page, and then avoid calling
revalidate.  In practice, the items endpoint is already not cached
anyway, since nextJS has some underlying magic to not cache any of the
data if 'dynamic' functions like `headers()` are called (we call this
method to fetch the client side IP address).

In practice, this should do nothing, except maybe reduce a tiny bit of
overhead in calling `revalidatePath`. I think this might just make some
of the cache behavior a bit clearer. Additionally, I think the purpose
of `revalidatePath` is to call it when data is mutated, ie, if you have
a form submission or button that triggers data updates, and you want to
wipe the cache so that the next GET isn't stale.  Since DC is read-only,
seems like we can avoid that step.

If this looks okay on QA, I may reevaluate our other uses of
revalidatePath as well.
@vercel
Copy link
Copy Markdown

vercel bot commented Sep 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
digital-collections Ready Ready Preview Comment Sep 29, 2025 7:53pm

clientIP = null,
isRepoApi = true,
next,
cache = "force-cache",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note - I set this as the default since this is the default in nextJS 14 per the docs

Comment on lines +43 to +47
logging: {
fetches: {
fullUrl: true,
},
},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this utility only runs in dev mode, but is handy to see when data is actually being fetched

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants