kornelski / http-cache-semantics

RFC 7234 in JavaScript. Parses HTTP headers to correctly compute cacheability of responses, even in complex cases
http://httpwg.org/specs/rfc7234.html
BSD 2-Clause "Simplified" License
244 stars 27 forks source link

rfc 5861 (stale-if-error, stale-while-revalidate) #30

Closed sithmel closed 4 years ago

sithmel commented 4 years ago

solves #27

sithmel commented 4 years ago

stale-if error works fine in cacheable-request https://github.com/lukechilds/cacheable-request/issues/94. Without changing the code. I have created a test case locally.

kornelski commented 4 years ago

Sorry, GitHub UI is stupid and I didn't notice that my comments weren't public yet

sithmel commented 4 years ago

I also added an easy way to mock time. Tests were randomly breaking otherwise.

kornelski commented 4 years ago

Please don't add unrelated functionality to a PR.

I don't like the mocking change. The now method exist specifically to be monkey-patched in tests, so it doesn't need another way of being patched.

sithmel commented 4 years ago

I have reverted the mock. I missed to realise that there was already a way. Thanks for spotting that!

I had to monkey patch now for a single test that was failing in CI.

kornelski commented 4 years ago

Thank you