Nextjs cache tags with page router

We hit a roadblock while experimenting with cache tags in a nextjs page router project. You can set cache tags but invalidating them will throw an error (Invariant: static generation store missing in revalidateTag). Looking at the documentation it seems that page router only support invalidating page cache based on path and not cache tags. Has anybody else tried this?

Hi @thomas.billiet, and welcome to the Dato forum!

Unfortunately, tag-based invalidation isn’t something the Page Router supports by default.

I mentioned some possible workarounds in this recent thread that you can consider: Next Js getStaticProps and Dato CMS Cache Tags

But it’ll have to be something you write yourself, or use a library + external KV store for :frowning:

Alternatively, traditional mechanisms like ISR (incremental static regeneration) should still work well with the page router. Since your fetches in that model are defined by the page anyway, ISR will rebuild just that one page anyway and naturally invalidate all the queries that page needs.