I'm trying to prevent the browser to cache on form pages and block the user to return after submit.
application_controller.rb
protected
def set_no_cache
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
another_controller.rb
before_filter :set_no_cache, only: [:new, :edit]
when add a byebug on the 'edit' action, for example, I see the headers correctly changed:
(byebug) headers
{"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content-Type-Options"=>"nosniff", "Cache-Control"=>"no-cache, no-store, max-age=0, must-revalidate", "Pragma"=>"no-cache", "Expires"=>"Fri, 01 Jan 1990 00:00:00 GMT"}
But it doesn't work to me and I tried on Ubuntu for Chrome, Opera and Safari browsers.