Skip to content

Instantly share code, notes, and snippets.

@humphreybc
Created October 19, 2017 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save humphreybc/86cfcea534111e68b2b4416d7edc4db9 to your computer and use it in GitHub Desktop.
Save humphreybc/86cfcea534111e68b2b4416d7edc4db9 to your computer and use it in GitHub Desktop.
require 'action_dispatch/middleware/static'
ActionDispatch::FileHandler.class_eval do
private
def gzip_file_path(path)
return false if ['image/png', 'image/jpeg', 'image/gif'].include? content_type(path)
gzip_path = "#{path}.gz"
if File.exist?(File.join(@root, ::Rack::Utils.unescape_path(gzip_path)))
gzip_path
else
false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment