Hi, I'm looking for a way to trigger an event once revalidateTag and the corresponding build have completed and the new data is cached. I'm looking for a way to notify several clients via WebSocket that this event has occurred and to re-fetch the data on the client.
The current need for this is because right now there's no way to know when the cache has be rebuilt and ready for clients to view. Once revalidateTag is called, this essentially triggers the cache to invalidate. While the cache is being rebuilt, the client is still receiving cached but stale data while the new cached tag is being populated.
This results in an event happening, but it can take several seconds for the clients to receive the update. I have also considered doing an optimistic update locally in the client and then it resolves once the new data comes back from the server, but this feels clunky and like it's extra complex on the client.
My original idea was make a separate fetch request to my WebSocket server that would broadcast to its clients that an update is available. I had looked at doing this in Middleware after the original fetch request was done, but it looks like NextFetchEvent has been removed in the App Directory.
Is there a simpler way to do this? I'd prefer not to make the additional fetch request within the Route Handler itself.