Add dns-prefetch if using different host for assets or uploads (#8942)

master
Eugen Rochko 6 years ago committed by GitHub
parent 46e4a759bb
commit da7705b274
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      app/helpers/application_helper.rb
  2. 7
      app/views/layouts/application.html.haml

@ -81,4 +81,20 @@ module ApplicationHelper
output << 'rtl' if locale_direction == 'rtl' output << 'rtl' if locale_direction == 'rtl'
output.reject(&:blank?).join(' ') output.reject(&:blank?).join(' ')
end end
def cdn_host
ENV['CDN_HOST'].presence
end
def cdn_host?
cdn_host.present?
end
def storage_host
ENV['S3_ALIAS_HOST'].presence || ENV['S3_CLOUDFRONT_HOST'].presence
end
def storage_host?
storage_host.present?
end
end end

@ -3,6 +3,13 @@
%head %head
%meta{ charset: 'utf-8' }/ %meta{ charset: 'utf-8' }/
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1' }/ %meta{ name: 'viewport', content: 'width=device-width, initial-scale=1' }/
- if cdn_host?
%link{ rel: 'dns-prefetch', href: cdn_host }/
- if storage_host?
%link{ rel: 'dns-prefetch', href: storage_host }/
%link{ rel: 'icon', href: favicon_path, type: 'image/x-icon' }/ %link{ rel: 'icon', href: favicon_path, type: 'image/x-icon' }/
%link{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }/ %link{ rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }/
%link{ rel: 'mask-icon', href: '/mask-icon.svg', color: '#2B90D9' }/ %link{ rel: 'mask-icon', href: '/mask-icon.svg', color: '#2B90D9' }/

Loading…
Cancel
Save