module NoCacheControl

Constants

VERSION

Public Class Methods

included(base) click to toggle source
# File lib/no_cache_control.rb, line 4
def self.included(base)
  begin
    base.before_action :set_no_cache_control
  rescue NoMethodError
    base.before_filter :set_no_cache_control
  end
end

Public Instance Methods

set_no_cache_control() click to toggle source
# File lib/no_cache_control.rb, line 12
def set_no_cache_control
  response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"

  # Pragma and Expires are not a true header defined in RFC, however some browsers accepts them
  response.headers["Pragma"] = "no-cache"
  response.headers["Expires"] = '-1'
end