try a speed hack using a Link: header for the stylesheet

probably only works in firefox though
This commit is contained in:
joshua stein 2015-02-11 10:58:34 -06:00
parent 7d15b5db6d
commit fe159cc3f7

View file

@ -1,8 +1,11 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user
before_filter :send_css_link_header
before_filter :increase_traffic_counter
@@_css_link_header = nil
TRAFFIC_DECREMENTER = 0.25
TAG_FILTER_COOKIE = :tag_filters
@ -18,6 +21,27 @@ class ApplicationController < ActionController::Base
true
end
# speed hax
@@_css_link_header = nil
def send_css_link_header
begin
if !@@_css_link_header
# is there a better way to find this?
j = JSON.parse(File.read(Dir.glob(
"#{Rails.root}/public/assets/manifest-*.json").first))
@@_css_link_header = "</assets/" << j["assets"]["application.css"] <<
">; rel=stylesheet"
end
rescue => e
Rails.logger.error e.inspect
end
if @@_css_link_header
response.headers["Link"] = @@_css_link_header
end
end
def increase_traffic_counter
@traffic = 1.0