diff --git a/app/models/post.rb b/app/models/post.rb index d60379b14..22f8156bf 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -105,16 +105,20 @@ class Post < ActiveRecord::Base end def file_url - # if cdn_hosted? - # Danbooru.config.danbooru_s3_base_url + "/#{file_path_prefix}#{md5}.#{file_ext}" - # else - "/data/#{seo_tag_string}#{file_path_prefix}#{md5}.#{file_ext}" - # end + if Danbooru.config.use_s3_proxy?(self) + "/cached/data/#{seo_tag_string}#{file_path_prefix}#{md5}.#{file_ext}" + else + "/data/#{seo_tag_string}#{file_path_prefix}#{md5}.#{file_ext}" + end end def large_file_url if has_large? - "/data/sample/#{seo_tag_string}#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}" + if Danbooru.config.use_s3_proxy?(self) + "/cached/data/sample/#{seo_tag_string}#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}" + else + "/data/sample/#{seo_tag_string}#{file_path_prefix}#{Danbooru.config.large_image_prefix}#{md5}.#{large_file_ext}" + end else file_url end diff --git a/config/danbooru_default_config.rb b/config/danbooru_default_config.rb index bbc0f771b..e2bbe7785 100644 --- a/config/danbooru_default_config.rb +++ b/config/danbooru_default_config.rb @@ -410,6 +410,11 @@ module Danbooru def addthis_key end + # enable s3-nginx proxy caching + def use_s3_proxy?(post) + post.id < 100 + end + # include essential tags in image urls (requires nginx/apache rewrites) def enable_seo_post_urls false