Next.js Discord

Discord Forum

Revalidate by both tag and time

Unanswered
Siberian posted this in #help-forum
Open in Discord
SiberianOP
Hey folks,

I ran into an issue with cache revalidation today:
export const getExperiment = async (props: GetExperimentProps): Promise<Experiment> => {
  const { projectName, orgName, envName, id } = props
  const userId = await getUserIdFromCookie()
  const tags = userId ? [`tag`] : undefined

  const res = await fetchWithAuth(`endpoint`, {
    next: {
      tags,
      revalidate: 300,
    },
  })

  if (!res.ok) {
    throw new Error('Failed to fetch experiment')
  }

  const data = await res.json()

  return data.experiment
}

Is it intended that my cache is only revalidated by tag in here? I wanted it to be both revalidated every 5mins and when that tag gets invalidated.

Anyone knows anything? Docs are never specifying that those can't be used together.

0 Replies