Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stale responses fail when Last-Modified is missing #85

Open
tylerhunt opened this issue Jul 6, 2013 · 1 comment
Open

Stale responses fail when Last-Modified is missing #85

tylerhunt opened this issue Jul 6, 2013 · 1 comment

Comments

@tylerhunt
Copy link

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
@dlindahl
Copy link

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?

tylerhunt added a commit to tylerhunt/rack-cache that referenced this issue Sep 19, 2013
When caching a request with headers like this:

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

Everything works fine while fresh, but once stale, an error is being
raised from within `Net::HTTP`, since there's no `Last-Modified` header.

Resolves rtomayko#85.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants