Conditional page cache and Webrick's handle_file()

Hey there! So, I’m trying to follow Edward’s approach to conditional
page caching:

http://www.ethelred.org/articles/2006/10/22/conditional-use-of-page-cache-in-rails

The idea is to only cache and display pages for anonymous visitors.
Here’s how he suggests editing webrick_server.rb:


def handle_file(req, res) #:nodoc:
begin
req = req.dup
path = req.path.dup
if path != ‘/’ && (%r{(^|/)[^./]+$} =~ path)
if(req.cookies.find{|c| c.name == “logged_in” && c.value ==
‘yes’})
return false
end
# Add .html if the last path piece has no . in it
path << ‘.html’
end
path.gsub!(‘+’, ’ ') # Unescape + since FileHandler doesn’t do
so.
req.instance_variable_set(:@path_info, path) # Set the modified
path…
@file_handler.send(:service, req, res)
return true
rescue HTTPStatus::PartialContent, HTTPStatus::NotModified => err
res.set_error(err)
return true
rescue => err
return false
end
end

Problem is, this isn’t skipping the cache as intended – it’s loading
the cache every time regardless of the cookie. Any ideas why this would
be?