Bug 143226 - Don't cache resources that are very unlikely to be reused
Summary: Don't cache resources that are very unlikely to be reused
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-03-30 09:37 PDT by Antti Koivisto
Modified: 2015-03-30 15:01 PDT (History)
7 users (show)

See Also:


Attachments
patch (27.68 KB, patch)
2015-03-30 10:40 PDT, Antti Koivisto
ggaren: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews104 for mac-mavericks-wk2 (588.82 KB, application/zip)
2015-03-30 11:45 PDT, Build Bot
no flags Details
patch (35.76 KB, patch)
2015-03-30 13:43 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
follow-up to cover no-cache (3.29 KB, patch)
2015-03-30 14:49 PDT, Antti Koivisto
cdumez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2015-03-30 09:37:22 PDT
Cache entries with 0 cache lifetime and no validation headers are generally not useful.
Comment 1 Radar WebKit Bug Importer 2015-03-30 09:38:38 PDT
<rdar://problem/20347160>
Comment 2 Chris Dumez 2015-03-30 09:47:27 PDT
What about history navigation and tab restoring after jetsam / crash?
Comment 3 Antti Koivisto 2015-03-30 09:50:29 PDT
I keep the current policy for main resources.
Comment 4 Chris Dumez 2015-03-30 09:57:21 PDT
The current pruning algorithm already takes care of dropping resources that were not reused first. I am slightly worried about being more aggressive here and completely not cache such resources. It will potentially cause us to use the radio more when using history navigations and on tab restore.
Comment 5 Antti Koivisto 2015-03-30 10:00:50 PDT
That balances against concerns of wasting cache space (so having less space for useful item) and power and performance effects of unnecessary disk writes.
Comment 6 Chris Dumez 2015-03-30 10:06:52 PDT
The pruning policy should hopefully address the issue for wasting cache space. This change could negatively affect <rdar://problem/19869257>. In airplane mode, it is not only an efficiency issue but the user would potentially loose useful content as we wouldn't be able to restore it.
Comment 7 Antti Koivisto 2015-03-30 10:40:08 PDT
Created attachment 249744 [details]
patch
Comment 8 WebKit Commit Bot 2015-03-30 10:42:30 PDT
Attachment 249744 [details] did not pass style-queue:


ERROR: Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:296:  Extra space before ( in function call  [whitespace/parens] [4]
Total errors found: 1 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Antti Koivisto 2015-03-30 10:47:22 PDT
The patch is still very conservative. Resources marked this uncacheable are generally one time xhr, ad ping images/scripts and similar. They are probably very rarely needed for a reasonably good tab restore. If we find problematic cases we can change the policy.
Comment 10 Geoffrey Garen 2015-03-30 10:58:36 PDT
Comment on attachment 249744 [details]
patch

r=me
Comment 11 Build Bot 2015-03-30 11:45:19 PDT
Comment on attachment 249744 [details]
patch

Attachment 249744 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6148567194402816

New failing tests:
http/tests/cache/disk-cache/disk-cache-request-max-stale.html
Comment 12 Build Bot 2015-03-30 11:45:24 PDT
Created attachment 249752 [details]
Archive of layout-test-results from ews104 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 13 Chris Dumez 2015-03-30 12:26:29 PDT
Comment on attachment 249744 [details]
patch

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

> Source/WebKit2/NetworkProcess/cache/NetworkCache.h:-69
> -    NoDueToAttachmentResponse,

We need to keep this one. We cannot shift values in this enum as they are stored in integers in the database.
Comment 14 Chris Dumez 2015-03-30 12:27:00 PDT
Comment on attachment 249744 [details]
patch

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

>> Source/WebKit2/NetworkProcess/cache/NetworkCache.h:-69
>> -    NoDueToAttachmentResponse,
> 
> We need to keep this one. We cannot shift values in this enum as they are stored in integers in the database.

We should probably add a comment for this enum to explain we cannot do this :) Sorry about that.
Comment 15 Chris Dumez 2015-03-30 12:30:05 PDT
Comment on attachment 249744 [details]
patch

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

> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:274
> +    bool hasExipirationHeaders = std::isfinite(response.expires()) || std::isfinite(response.cacheControlMaxAge());

hasExipirationHeaders ? :D typo.
Comment 16 Chris Dumez 2015-03-30 12:37:18 PDT
Comment on attachment 249744 [details]
patch

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

> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:283
> +    bool storeUnconditionallyForBackNavigation = originalRequest.priority() == WebCore::ResourceLoadPriorityVeryHigh;

I would say "ForHistoryNavigation".
Comment 17 Antti Koivisto 2015-03-30 13:43:36 PDT
Created attachment 249759 [details]
patch
Comment 18 Chris Dumez 2015-03-30 13:54:04 PDT
Comment on attachment 249759 [details]
patch

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

ok

> Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp:281
> +        auto currentTime = std::chrono::duration<double>(std::chrono::system_clock::now().time_since_epoch());

auto now = currentTime(); ?

c.f. NetworkResourceLoader::didFinishLoading().

> LayoutTests/http/tests/cache/disk-cache/disk-cache-request-max-stale.html:30
> +

nit: extra line?
Comment 19 Antti Koivisto 2015-03-30 14:05:38 PDT
> > +        auto currentTime = std::chrono::duration<double>(std::chrono::system_clock::now().time_since_epoch());
> 
> auto now = currentTime(); ?

We should move to std::chrono everywhere.
Comment 20 Antti Koivisto 2015-03-30 14:10:34 PDT
https://trac.webkit.org/r182152
Comment 21 Antti Koivisto 2015-03-30 14:49:17 PDT
Created attachment 249766 [details]
follow-up to cover no-cache
Comment 22 Chris Dumez 2015-03-30 14:57:17 PDT
Comment on attachment 249766 [details]
follow-up to cover no-cache

r=me
Comment 23 Antti Koivisto 2015-03-30 15:01:45 PDT
Follow-up for no-cache case: https://trac.webkit.org/r182154