rack-cache icon indicating copy to clipboard operation
rack-cache copied to clipboard

Stale responses fail when Last-Modified is missing

Open tylerhunt opened this issue 11 years ago • 1 comments

I'm running into an issue caching responses with headers like this:

Cache-Control: max-age=300, public
ETag: "5c564d692c85b70068fd76ea25f2be2f"

While fresh, this works fine, but once stale, Net::HTTP is raising this error:

NoMethodError: undefined method `strip' for nil:NilClass
        from ~/.rbenv/versions/1.9.3-p448/lib/ruby/1.9.1/net/http.rb:1436:in `block in initialize_http_header'

The issue appears to be in lib/rack/cache/context.rb. This change fixes it:

197c197
<       @env['HTTP_IF_MODIFIED_SINCE'] = entry.last_modified

---
>       @env['HTTP_IF_MODIFIED_SINCE'] = entry.last_modified if entry.last_modified

tylerhunt avatar Jul 06 '13 00:07 tylerhunt

I am also seeing this error. A similar work around by-passed the issue.

@tylerhunt Why don't you submit a Pull Request since you've already included a patch in your original Issue?

dlindahl avatar Sep 13 '13 19:09 dlindahl