Created
April 16, 2014 22:20
-
-
Save harlow/10938652 to your computer and use it in GitHub Desktop.
Rails 4 cache_control headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_cache_control_headers(max_age = 1.second.to_s) | |
if request.method == "GET" | |
request.session_options[:skip] = true | |
response.cache_control[:public] = true | |
response.cache_control[:extras] = ['no-cache'] | |
response.headers['Surrogate-Control'] = "max-age=#{max_age}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment