Added a little documentation to TurboDev middleware
This commit is contained in:
parent
886787b157
commit
21e08a423e
|
@ -1,12 +1,22 @@
|
|||
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
|
||||
def initialize(app, settings={})
|
||||
@app = app
|
||||
end
|
||||
def call(env)
|
||||
|
||||
def call(env)
|
||||
is_asset = (env['REQUEST_PATH'] =~ /^\/assets\//)
|
||||
|
||||
# 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]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue