mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -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
|
||||
|
||||
expires_in 1.year, public: true
|
||||
|
||||
response.headers["Expires"] = 1.year.from_now.httpdate
|
||||
response.headers["Access-Control-Allow-Origin"] = params[:origin]
|
||||
|
||||
begin
|
||||
response.headers["Last-Modified"] = File.ctime(path).httpdate
|
||||
response.headers["Content-Length"] = File.size(path)
|
||||
rescue Errno::ENOENT
|
||||
raise Discourse::NotFound
|
||||
end
|
||||
opts = {
|
||||
disposition: nil
|
||||
}
|
||||
opts[:type] = "application/x-javascript" if path =~ /\.js$/
|
||||
|
||||
opts[:type] = "application/javascript" if path =~ /\.js$/
|
||||
|
||||
# we must disable acceleration otherwise NGINX strips
|
||||
# access control headers
|
||||
|
|
Loading…
Reference in a new issue