0

I'm using jQuery and Laravel's session flash data to show a notification after every CRUD action. For example:

/*
*
* Update code goes here
*/
return Redirect::route('profile')->with('flashMessage', 'Profile updated');

The flash data is by definition available only for the next request. However, if I go to another page (directly after the notification was shown) and hit the browser back button, the flash data is still there, causing the notification to show up again, but this time with no logical reason.

Is there a way to prevent this? I'm testing in Chrome.

lesssugar
  • 15,486
  • 18
  • 65
  • 115
  • Are you sure the browser is requesting a new page instead of just displaying the old one ? You may need to tinker with cache control headers. –  Jan 20 '15 at 12:21
  • Sure, the thing is that the browser actually does not make a new request, but renders the previous page. I would like to know what is the way to handle this. – lesssugar Jan 20 '15 at 12:22
  • 1
    Try serving the page with the following header : `Cache-Control: no-store, no-cache, must-revalidate, max-age=0`. –  Jan 20 '15 at 12:24
  • This is just normal 'back button' behavior. There are many posts on SO about this already. – Laurence Jan 20 '15 at 12:25

0 Answers0