Created
September 9, 2013 05:13
-
-
Save hasclass/6491723 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# --- BEFORE --- | |
module Rack | |
class ETag | |
def call(env) | |
# ... | |
unless headers['Cache-Control'] | |
if digest | |
headers['Cache-Control'] = @cache_control if @cache_control | |
else | |
headers['Cache-Control'] = @no_cache_control if @no_cache_control | |
end | |
end | |
# ... | |
end | |
# ... | |
def skip_caching?(headers) | |
(headers['Cache-Control'] && headers['Cache-Control'].include?('no-cache')) || | |
headers.key?('ETag') || headers.key?('Last-Modified') | |
end | |
# ... | |
end | |
end | |
# --- AFTER ---- | |
module Rack | |
HEADER_CACHE_CONTROL = "Cache-Control".freeze | |
class ETag | |
def call(env) | |
# ... | |
unless headers[HEADER_CACHE_CONTROL] | |
if digest | |
headers[HEADER_CACHE_CONTROL] = @cache_control if @cache_control | |
else | |
headers[HEADER_CACHE_CONTROL] = @no_cache_control if @no_cache_control | |
end | |
end | |
# ... | |
end | |
# ... | |
def skip_caching?(headers) | |
(headers[HEADER_CACHE_CONTROL] && headers[HEADER_CACHE_CONTROL].include?('no-cache')) || | |
headers.key?('ETag') || headers.key?('Last-Modified') | |
end | |
# ... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment