Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Humphrey humphreybc

View GitHub Profile
View serve_gzip_images.rb
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
You can’t perform that action at this time.