Static file handler for Rails < 2.3. This handler is only provided as a convenience for developers. Performance-minded deployments should use nginx (or similar) for serving static files.
This supports page caching directly and will try to resolve a request in the following order:
This means that if you are using page caching it will actually work with Unicorn and you should see a decent speed boost (but not as fast as if you use a static server like nginx).
avoid allocating new strings for hash lookups
(Not documented)
# File lib/unicorn/app/old_rails/static.rb, line 36
36: def call(env)
37: # short circuit this ASAP if serving non-file methods
38: FILE_METHODS.include?(env[REQUEST_METHOD]) or return app.call(env)
39:
40: # first try the path as-is
41: path_info = env[PATH_INFO].chomp("/")
42: if File.file?("#{root}/#{::Rack::Utils.unescape(path_info)}")
43: # File exists as-is so serve it up
44: env[PATH_INFO] = path_info
45: return file_server.call(env)
46: end
47:
48: # then try the cached version:
49: path_info << ActionController::Base.page_cache_extension
50:
51: if File.file?("#{root}/#{::Rack::Utils.unescape(path_info)}")
52: env[PATH_INFO] = path_info
53: return file_server.call(env)
54: end
55:
56: app.call(env) # call OldRails
57: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.