kaazing / http2-cache.js

2 stars 11 forks source link

stale-while-revalidate cache-directive semantics should be respected #64

Closed dpwspoon closed 6 years ago

dpwspoon commented 6 years ago

Stale-while-revalidate is defined here.

It allows serving a stale cache response if the cache is in the process of refreshing it's entry. We interpret this to mean, that it is okay to serve it from cache IF there is an outstanding push promise.

This is not properly implemented today: https://github.com/kaazing/http2-cache.js/blob/3cf0baa0927e2fb1320f3de04d952f60bc839cb9/lib/cache.js#L141.

We should only use the stale-while-revalidate value in the comparison maxAgeAt > staleButRevalidateAt ? maxAgeAt : staleButRevalidateAt; IF there is a inflight push promise that matches the requestInfo.

If there is no inflight push promise with request info that matches, then we should ignore the stale-while-revalidate cache extension.

hthetiot commented 6 years ago

merged https://github.com/kaazing/http2-cache.js/pull/66