Fetch options. What is the priority/outcome of combining revalidate AND tags? #70355
Unanswered
james2doyle
asked this question in
Help
Replies: 1 comment 1 reply
-
Hi, As far as I can see, the revalidate by time, and by tags, should not interfere with each other. So yeah, you can use both. I looked at the implementation of these, and then ran a couple of tests in production mode. export default async function Home() {
const num = await fetch(
"https://www.random.org/integers/?num=1&min=1&max=1000&col=1&base=10&format=plain&rnd=new",
{
next: {
revalidate: 60,
tags: ["rng"],
},
},
).then((res) => res.text());
return <div>Hello {num}</div>;
} And this revalidate route: import { revalidateTag } from "next/cache";
export const dynamic = "force-dynamic";
export async function GET() {
revalidateTag("rng");
return Response.json({ revalidated: true, now: Date.now() });
} After building, I go to the home page, and see a number, then I can revalidate the tag running this on my browser console: fetch("/tag").then(res => res.json()).then(console.log) And reloading the page, shows a new number (assuming you don't get the same random number...), and then waiting 60 seconds, to then do a |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Anyone know what happens when you use using the
fetch
cache controls for options.next.revalidate and options.next.tags together with ISR?Will revalidate be ignored when a tag is being used or will revalidate be honored, and the freshest data will be based on that?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions