tell browsers they can cache can assets for a year
test plan: * first, clear out all the cdn assets on your test s3 bucket by running this in rails console: Canvas::CDN::S3Uploader.new.bucket.objects.with_prefix('dist').delete_all * compile_assets * run bundle exec rake canvas:cdn:upload_to_s3 * access canvas in your browser * on js/css/image assets (like common-xxxxx.js) you should see a "max age 1 year" header Change-Id: I7847e614a0e3066686bda32f8854263f78cc168f Reviewed-on: https://gerrit.instructure.com/59184 Tested-by: Jenkins Reviewed-by: Cody Cutrer <cody@instructure.com> QA-Review: Jeremy Putnam <jeremyp@instructure.com> Product-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
parent
0531e3e4f4
commit
5408a67c0d
|
@ -29,8 +29,8 @@ module Canvas
|
|||
end
|
||||
end
|
||||
|
||||
def fingerprint?(path)
|
||||
/-[0-9a-fA-F]{32}$/.match(path.basename(path.extname).to_s)
|
||||
def fingerprinted?(path)
|
||||
/-[0-9a-fA-F]{10}$/.match(path.basename(path.extname).to_s)
|
||||
end
|
||||
|
||||
def font?(path)
|
||||
|
@ -43,10 +43,9 @@ module Canvas
|
|||
|
||||
def options_for(path)
|
||||
options = {acl: :public_read, content_type: mime_for(path)}
|
||||
if fingerprint?(path)
|
||||
if fingerprinted?(path)
|
||||
options.merge!({
|
||||
cache_control: "public, max-age=#{1.year}",
|
||||
expires: 1.year.from_now.httpdate
|
||||
cache_control: "public, max-age=#{1.year}"
|
||||
})
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue