Current section: Server Actions 27 exercises
Problem

History Revalidation

Loading exercise

Transcript

00:00 We've got one more problem we want to deal with, and that is, what happens if somebody comes in around here and they're just very excited, so they're adding an exclamation point for each one of these. And so we're updating this promise cache for each one of these to have an exclamation point. But if we hit the back button, check it out.

00:18 These do not have exclamation points until we get to the point in history when they did. And this resembles the way that the web works, the way the browser does this, is it's going to hang on to the previous values, even if they were mutated or whatever. That's just how it works. But we're going to make the product decision to say, no, I'm not happy with that, and I

00:36 want to revalidate every time pop state happens. Different routers are going to do different things and whatever. This is definitely a product decision thing. But I think that it makes sense to revalidate when a pop state event happens like this. So basically what we need to do is, before, we were saying, hey, go ahead and update the

00:56 content if we don't have a content promise there. Now we're going to go and update the content regardless. Either way, whenever a pop state happens, go update the content. And when that streaming content finishes, then update the client cache to that new content. So that is your job here. It should be pretty quick.