From 47e02e9ddc4a7b36171adbe52746719852448fe6 Mon Sep 17 00:00:00 2001 From: Ronald Hsu Date: Thu, 25 Feb 2016 17:05:37 +0800 Subject: [PATCH 1/2] fix font related file mime type nil problem --- lib/asset_sync/multi_mime.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/asset_sync/multi_mime.rb b/lib/asset_sync/multi_mime.rb index 9bb59b13..5ddaabf8 100644 --- a/lib/asset_sync/multi_mime.rb +++ b/lib/asset_sync/multi_mime.rb @@ -11,8 +11,8 @@ def self.lookup(ext) ext_with_dot = ".#{ext}" Rack::Mime.mime_type(ext_with_dot) else - ::MIME::Types.type_for(ext).first - end + nil + end || ::MIME::Types.type_for(ext).first end From 4a42923ff5066144c3a652abbbe124117ed4d9c0 Mon Sep 17 00:00:00 2001 From: Ronald Hsu Date: Thu, 3 Mar 2016 21:33:38 +0800 Subject: [PATCH 2/2] all assets sync with cache control header --- lib/asset_sync/storage.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/asset_sync/storage.rb b/lib/asset_sync/storage.rb index c67691c4..a4633558 100644 --- a/lib/asset_sync/storage.rb +++ b/lib/asset_sync/storage.rb @@ -134,16 +134,11 @@ def upload_file(f) :key => f, :body => File.open("#{path}/#{f}"), :public => true, - :content_type => mime + :content_type => mime, + :cache_control => "public, max-age=#{one_year}", + :expires => CGI.rfc1123_date(Time.now + one_year) } - if /-[0-9a-fA-F]{32}$/.match(File.basename(f,File.extname(f))) - file.merge!({ - :cache_control => "public, max-age=#{one_year}", - :expires => CGI.rfc1123_date(Time.now + one_year) - }) - end - # overwrite headers if applicable, you probably shouldn't specific key/body, but cache-control headers etc. if files_with_custom_headers.has_key? f