mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Apply syntax_tree formatting to lib/*
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
module Middleware
|
||||
|
||||
# Cheat and bypass Rails in development mode if the client attempts to download a static asset
|
||||
# that's already been downloaded.
|
||||
#
|
||||
@@ -19,22 +18,19 @@ module Middleware
|
||||
|
||||
def call(env)
|
||||
root = "#{GlobalSetting.relative_url_root}/assets/"
|
||||
is_asset = env['REQUEST_PATH'] && env['REQUEST_PATH'].starts_with?(root)
|
||||
is_asset = env["REQUEST_PATH"] && env["REQUEST_PATH"].starts_with?(root)
|
||||
|
||||
# hack to bypass all middleware if serving assets, a lot faster 4.5 seconds -> 1.5 seconds
|
||||
if (etag = env['HTTP_IF_NONE_MATCH']) && is_asset
|
||||
name = env['REQUEST_PATH'][(root.length)..-1]
|
||||
if (etag = env["HTTP_IF_NONE_MATCH"]) && is_asset
|
||||
name = env["REQUEST_PATH"][(root.length)..-1]
|
||||
etag = etag.gsub "\"", ""
|
||||
asset = Rails.application.assets.find_asset(name)
|
||||
if asset && asset.digest == etag
|
||||
return [304, {}, []]
|
||||
end
|
||||
return 304, {}, [] if asset && asset.digest == etag
|
||||
end
|
||||
|
||||
status, headers, response = @app.call(env)
|
||||
headers['Cache-Control'] = 'no-cache' if is_asset
|
||||
headers["Cache-Control"] = "no-cache" if is_asset
|
||||
[status, headers, response]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user