Skip to content

Instantly share code, notes, and snippets.

@hasclass
Created September 9, 2013 05:13
Show Gist options
  • Save hasclass/6491723 to your computer and use it in GitHub Desktop.
Save hasclass/6491723 to your computer and use it in GitHub Desktop.
# --- 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