I'm using jQuery with a Rails 3 backend and I have the following scenario:
- User see's a comment on their post and wants to delete it
- User clicks the delete button and deletes the comment from the database
- jQuery uses
remove()
to remove the item from the DOM as an AJAX success response to step 2 above - User navigates to a different page
- User hits the back button to go back to the page with the comment
- The old comment is still there, even though it was removed from the server and from the DOM
The comment in this scenario is obviously being cached by the browser and so it shows up even though it was previously deleted (and it doesn't exist on the server either).
How do you prevent the comment (or prior cached objects that have been removed from the DOM) from showing up when the user hits the back button?
By the way: Please don't say, "don't cache any pages" :) That is not an option.