Bug 143159 - [WK2][NetworkCache] Add support for "Cache-Control: max-stale" request header
Summary: [WK2][NetworkCache] Add support for "Cache-Control: max-stale" request header
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://tools.ietf.org/html/rfc7234#s...
Keywords: InRadar
Depends on: 143121
Blocks:
  Show dependency treegraph
 
Reported: 2015-03-27 15:39 PDT by Chris Dumez
Modified: 2015-03-30 10:36 PDT (History)
4 users (show)

See Also:


Attachments
Patch (14.52 KB, patch)
2015-03-27 16:15 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (14.61 KB, patch)
2015-03-30 09:03 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2015-03-27 15:39:25 PDT
Add support for "Cache-Control: max-stale" request header:
https://tools.ietf.org/html/rfc7234#section-5.2.1.2
Comment 1 Radar WebKit Bug Importer 2015-03-27 15:39:44 PDT
<rdar://problem/20333296>
Comment 2 Chris Dumez 2015-03-27 16:15:08 PDT
Created attachment 249619 [details]
Patch
Comment 3 Antti Koivisto 2015-03-28 07:41:33 PDT
We are now getting to really obscure corners of the spec. Are there any indications that anyone uses this?
Comment 4 Antti Koivisto 2015-03-28 08:09:11 PDT
Comment on attachment 249619 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=249619&action=review

Well I suppose it is a potentially useful feature even if it is unknown. 

r=me but please consider factoring it differently.

> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:168
>      bool hasExpired = age > lifetime;
> +    if (hasExpired && !std::isnan(maxStale)) {
> +        // Request is allowing stale responses.
> +        // https://tools.ietf.org/html/rfc7234#section-5.2.1.2.
> +        if ((age - lifetime) < maxStale)
> +            hasExpired = false;
> +    }

maxStale = std::isnan(maxStale) ? 0 : maxStale;
bool hasExpired = age - lifetime > maxStale;

> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:181
> +static bool requestRequiresRevalidation(const WebCore::ResourceRequest& request, double& maxStale)
>  {
>      auto requestDirectives = WebCore::parseCacheControlDirectives(request.httpHeaderFields());
> +    maxStale = requestDirectives.maxStale;

This is a bit strange way to factor this. We should probably combine requestRequiresRevalidation and responseHasExpired since you really need to be looking at both request and response to implement all semantics.
Comment 5 Chris Dumez 2015-03-30 09:03:21 PDT
Created attachment 249732 [details]
Patch
Comment 6 WebKit Commit Bot 2015-03-30 10:36:27 PDT
Comment on attachment 249732 [details]
Patch

Clearing flags on attachment: 249732

Committed r182145: <http://trac.webkit.org/changeset/182145>
Comment 7 WebKit Commit Bot 2015-03-30 10:36:31 PDT
All reviewed patches have been landed.  Closing bug.