correct headers and add better caching

This commit is contained in:
Sam 2016-12-05 15:10:54 +11:00
parent 55b35a05ed
commit 8a98d617df
2 changed files with 2 additions and 1 deletions

View File

@ -136,6 +136,7 @@ class StaticController < ApplicationController
opts[:type] = "application/javascript" if path =~ /\.js.br$/
response.headers["Expires"] = 1.year.from_now.httpdate
response.headers["Cache-Control"] = 'max-age=31557600, public'
response.headers["Content-Encoding"] = 'br'
begin
response.headers["Last-Modified"] = File.ctime(path).httpdate

View File

@ -49,7 +49,7 @@ module ApplicationHelper
if GlobalSetting.cdn_url &&
GlobalSetting.cdn_url.start_with?("https") &&
ENV["COMPRESS_BROTLI"] == "1" &&
request.env["ACCEPT_ENCODING"] =~ /br/
request.env["HTTP_ACCEPT_ENCODING"] =~ /br/
tags = javascript_include_tag(*args)
tags.gsub!("#{GlobalSetting.cdn_url}/assets/", "#{GlobalSetting.cdn_url}/brotli_asset/")
tags.html_safe