mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
Added a little documentation to TurboDev middleware
This commit is contained in:
parent
886787b157
commit
21e08a423e
1 changed files with 14 additions and 3 deletions
|
@ -1,12 +1,22 @@
|
||||||
module Middleware
|
module Middleware
|
||||||
# this class cheats and bypasses rails altogether if the client attempts
|
|
||||||
# to download a static asset
|
# Cheat and bypass Rails in development mode if the client attempts to download a static asset
|
||||||
|
# that's already been downloaded.
|
||||||
|
#
|
||||||
|
# Also ensures that assets are not cached in development mode. Around Chrome 29, the behavior
|
||||||
|
# of `must-revalidate` changed and would often not request assets that had changed.
|
||||||
|
#
|
||||||
|
# To use, include in your project and add the following to development.rb:
|
||||||
|
#
|
||||||
|
# require 'middleware/turbo_dev'
|
||||||
|
# config.middleware.insert 0, Middleware::TurboDev
|
||||||
|
#
|
||||||
class TurboDev
|
class TurboDev
|
||||||
def initialize(app, settings={})
|
def initialize(app, settings={})
|
||||||
@app = app
|
@app = app
|
||||||
end
|
end
|
||||||
def call(env)
|
|
||||||
|
|
||||||
|
def call(env)
|
||||||
is_asset = (env['REQUEST_PATH'] =~ /^\/assets\//)
|
is_asset = (env['REQUEST_PATH'] =~ /^\/assets\//)
|
||||||
|
|
||||||
# hack to bypass all middleware if serving assets, a lot faster 4.5 seconds -> 1.5 seconds
|
# hack to bypass all middleware if serving assets, a lot faster 4.5 seconds -> 1.5 seconds
|
||||||
|
@ -24,4 +34,5 @@ module Middleware
|
||||||
[status, headers, response]
|
[status, headers, response]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue