FEATURE: add immutable caching to rails site of things

This commit is contained in:
Sam
2017-02-23 13:05:00 -05:00
parent eee22bf037
commit f15f61da0a
6 changed files with 16 additions and 10 deletions

View File

@ -117,7 +117,7 @@ class StaticController < ApplicationController
response.headers["Content-Length"] = @@default_favicon.bytesize.to_s
render text: @@default_favicon, content_type: "image/png"
else
expires_in 1.year, public: true
immutable_for 1.year
response.headers["Expires"] = 1.year.from_now.httpdate
response.headers["Content-Length"] = data.bytesize.to_s
response.headers["Last-Modified"] = Time.new('2000-01-01').httpdate
@ -151,7 +151,7 @@ class StaticController < ApplicationController
response.headers["Cache-Control"] = 'max-age=31557600, public'
response.headers["Content-Encoding"] = 'br'
expires_in 1.year, public: true, must_revalidate: false
immutable_for 1.year
send_file(path, opts)
end
@ -163,7 +163,7 @@ class StaticController < ApplicationController
# SECURITY what if path has /../
raise Discourse::NotFound unless path.start_with?(Rails.root.to_s + "/public/assets")
expires_in 1.year, public: true
immutable_for 1.year
response.headers["Expires"] = 1.year.from_now.httpdate
response.headers["Access-Control-Allow-Origin"] = params[:origin] if params[:origin]