You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trigger subsequent actions for a route when it is revalidated, even if revalidated by tag.
Non-Goals
No response
Background
The cache tag revalidation system is brilliant, but sometimes there are actions that need to be taken when a route is updated that do not come out of the box with Next. For instance, if using Next behind a CDN, when a tag is revalidated, we also need a way to invalidate the affected routes on the CDN.
To my knowledge there is currently no way to do this—I have asked on Discord and help forum and got no responses.
Thus, we need a method to get all routes associated with a tag, in order to perform these actions.
Proposal
I propose exposing a method to get routes associated with a tag. There are a couple ways I could see doing this.
1a.) A new getRoutesByTag function that we could use in API endpoints:
2.) Another approach would be to expose an “onRevalidate” callback on page files. This would be give us control of what happens when the route(s) generated by this file are revalidated.
Method 1 would be a more global solution, and could cover off on things like the unstable_cache function. Method 2 would give you more granular control over what happens for particular route segments.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Non-Goals
No response
Background
The cache tag revalidation system is brilliant, but sometimes there are actions that need to be taken when a route is updated that do not come out of the box with Next. For instance, if using Next behind a CDN, when a tag is revalidated, we also need a way to invalidate the affected routes on the CDN.
To my knowledge there is currently no way to do this—I have asked on Discord and help forum and got no responses.
Thus, we need a method to get all routes associated with a tag, in order to perform these actions.
Proposal
I propose exposing a method to get routes associated with a tag. There are a couple ways I could see doing this.
1a.) A new
getRoutesByTag
function that we could use in API endpoints:1b.) Or, it would be nifty if the revalidateTag function returned the affected routes.
2.) Another approach would be to expose an “onRevalidate” callback on page files. This would be give us control of what happens when the route(s) generated by this file are revalidated.
Method 1 would be a more global solution, and could cover off on things like the
unstable_cache
function. Method 2 would give you more granular control over what happens for particular route segments.Beta Was this translation helpful? Give feedback.
All reactions