Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't let the browser show a cached transition page #254

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base
include GDS::SSO::ControllerMethods

before_filter :require_signin_permission!
before_filter :set_cache_buster

protect_from_forgery

Expand All @@ -23,6 +24,13 @@ def render_error(status, options={})
render "errors/error_#{status}", status: status, layout: 'error_page'
end

# http://stackoverflow.com/questions/711418/how-to-prevent-browser-page-caching-in-rails
def set_cache_buster
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a private method?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, though so should the other methods here...

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

private
def verify_authenticity_token
raise ActionController::InvalidAuthenticityToken unless verified_request?
Expand Down