3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/cloud_assets_controller.rb', line 3
def content
asset_response = cloud_asset request.fullpath
if asset_response.success?
content_type = asset_response.['Content-type']
if content_type.kind_of? Array
content_type = content_type.pop
end
if content_type =~ /text\/html/
set_remote_layout asset_response
response.['Cache-Control'] = 'no-cache, no-store, must-revalidate, max-age=0'
render :html => ''
elsif content_type =~ /javascript/
response.['Cache-Control'] = "max-age=#{CloudAssets::javascript_max_age_seconds}"
body = CloudAssets::fixup_javascript(asset_response.body.gsub CloudAssets::origin,'')
send_data body, :type => content_type, :disposition => 'inline'
elsif content_type =~ /css/
response.['Cache-Control'] = "max-age=#{CloudAssets::css_max_age_seconds}"
body = CloudAssets::fixup_css(asset_response.body.gsub CloudAssets::origin, CloudAssets::cdn)
send_data body, :type => content_type, :disposition => 'inline'
else
response.['Cache-Control'] = "max-age=#{CloudAssets::other_max_age_seconds}"
send_data asset_response.body, :type => content_type, :disposition => 'inline'
end
else
render :status => :not_found
end
end
|