Flash reapperas on refresh

How to prevent flash messages from reappearing when a page is

I show flash message through javascript, that basically created an
overlay div and shows the flash. When the the overlay is dismissed the
flash div’s contents are emptied as well, but I notice that when a
page is refreshed (for example, user logs in -> gets redirected to
home page -> is shown “Welcome user” flash), the flash message keeps


<% if !flash.nil? %>
<% if flash[:notice] %>

<% end %>
<% if flash[:success] %>

<% end %>
<% if flash[:error] %>

<% end %>
<% end %>

function showFlash(msg, tp) {
if ($(’#flash_messages_container’).length > 0) {

var flashContainer = $("<div id='flash_messages_container'

class=‘flash-messages " + tp + " ‘>");

" + msg +
opacity : .1
}, ‘500’, function(){
flashContainer.css(‘opacity’, 1)
$(‘body’).css(‘margin-top’, flashContainer.outerHeight());
$(’#close_flash’).click(function() {
$(‘body’).css(‘margin-top’, ‘0’);


I suspect this is happening since I starting using etags for cient
side and reverse proxy caching. So I guess the refresh is simply
loading the cached page, which contains the flash messages in the
flash container. So how do people discard flash when caching is

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs