mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-28 01:56:01 -05:00
Clean up content type and add Expires header when serving CDN assets
This commit is contained in:
parent
4eb1288dba
commit
4e7057efb1
1 changed files with 6 additions and 1 deletions
|
@ -86,16 +86,21 @@ class StaticController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
expires_in 1.year, public: true
|
expires_in 1.year, public: true
|
||||||
|
|
||||||
|
response.headers["Expires"] = 1.year.from_now.httpdate
|
||||||
response.headers["Access-Control-Allow-Origin"] = params[:origin]
|
response.headers["Access-Control-Allow-Origin"] = params[:origin]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
response.headers["Last-Modified"] = File.ctime(path).httpdate
|
response.headers["Last-Modified"] = File.ctime(path).httpdate
|
||||||
|
response.headers["Content-Length"] = File.size(path)
|
||||||
rescue Errno::ENOENT
|
rescue Errno::ENOENT
|
||||||
raise Discourse::NotFound
|
raise Discourse::NotFound
|
||||||
end
|
end
|
||||||
opts = {
|
opts = {
|
||||||
disposition: nil
|
disposition: nil
|
||||||
}
|
}
|
||||||
opts[:type] = "application/x-javascript" if path =~ /\.js$/
|
|
||||||
|
opts[:type] = "application/javascript" if path =~ /\.js$/
|
||||||
|
|
||||||
# we must disable acceleration otherwise NGINX strips
|
# we must disable acceleration otherwise NGINX strips
|
||||||
# access control headers
|
# access control headers
|
||||||
|
|
Loading…
Reference in a new issue