Bug 208381 - Add quirk to disable to back/forward cache on docs.google.com
Summary: Add quirk to disable to back/forward cache on docs.google.com
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-02-28 10:37 PST by Chris Dumez
Modified: 2020-03-02 23:18 PST (History)
8 users (show)

See Also:


Attachments
Patch (2.40 KB, patch)
2020-02-28 10:38 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (2.81 KB, patch)
2020-02-28 17:01 PST, 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 2020-02-28 10:37:06 PST
Add quirk to disable to back/forward cache on docs.google.com.

docs.google.com used to bypass the back/forward cache by serving "Cache-Control: no-store" over HTTPS. We started caching such content in r250437 but the docs.google.com content unfortunately is not currently compatible because it puts an overlay over the page and starts an animation when navigating away and fails to remove those when coming back from the back/forward cache (e.g. in 'pageshow' event handler).
Comment 1 Chris Dumez 2020-02-28 10:37:22 PST
<rdar://problem/59893415>
Comment 2 Chris Dumez 2020-02-28 10:38:36 PST
Created attachment 391990 [details]
Patch
Comment 3 Ryosuke Niwa 2020-02-28 13:42:48 PST
Comment on attachment 391990 [details]
Patch

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

> Source/WebCore/page/Quirks.cpp:634
> +    if (topURL.protocolIs("https") && equalLettersIgnoringASCIICase(host, "docs.google.com")) {

Hm... this wouldn't work with Google's hosted apps, would it?
Comment 4 Chris Dumez 2020-02-28 13:44:19 PST
(In reply to Ryosuke Niwa from comment #3)
> Comment on attachment 391990 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=391990&action=review
> 
> > Source/WebCore/page/Quirks.cpp:634
> > +    if (topURL.protocolIs("https") && equalLettersIgnoringASCIICase(host, "docs.google.com")) {
> 
> Hm... this wouldn't work with Google's hosted apps, would it?

Good point. Ideally, we'd find another way to detect google docs which does not rely on the host. Will need to think about it.
Comment 5 Ryosuke Niwa 2020-02-28 13:53:47 PST
(In reply to Chris Dumez from comment #4)
> (In reply to Ryosuke Niwa from comment #3)
> > Comment on attachment 391990 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=391990&action=review
> > 
> > > Source/WebCore/page/Quirks.cpp:634
> > > +    if (topURL.protocolIs("https") && equalLettersIgnoringASCIICase(host, "docs.google.com")) {
> > 
> > Hm... this wouldn't work with Google's hosted apps, would it?
> 
> Good point. Ideally, we'd find another way to detect google docs which does
> not rely on the host. Will need to think about it.

Do they add some kind of event listener, meta tag, etc... that makes it easy to target?
Comment 6 Chris Dumez 2020-02-28 17:01:28 PST
Created attachment 392034 [details]
Patch
Comment 7 Chris Dumez 2020-02-28 17:02:43 PST
(In reply to Ryosuke Niwa from comment #5)
> (In reply to Chris Dumez from comment #4)
> > (In reply to Ryosuke Niwa from comment #3)
> > > Comment on attachment 391990 [details]
> > > Patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=391990&action=review
> > > 
> > > > Source/WebCore/page/Quirks.cpp:634
> > > > +    if (topURL.protocolIs("https") && equalLettersIgnoringASCIICase(host, "docs.google.com")) {
> > > 
> > > Hm... this wouldn't work with Google's hosted apps, would it?
> > 
> > Good point. Ideally, we'd find another way to detect google docs which does
> > not rely on the host. Will need to think about it.
> 
> Do they add some kind of event listener, meta tag, etc... that makes it easy
> to target?

Here is an alternative fix that works by detecting the overlay that they put on top of the page when navigating away.
Comment 8 Ryosuke Niwa 2020-02-28 21:46:40 PST
Comment on attachment 392034 [details]
Patch

Looks good to me.
Comment 9 Chris Dumez 2020-03-02 08:25:28 PST
Comment on attachment 392034 [details]
Patch

Clearing flags on attachment: 392034

Committed r257714: <https://trac.webkit.org/changeset/257714>
Comment 10 Chris Dumez 2020-03-02 08:25:30 PST
All reviewed patches have been landed.  Closing bug.
Comment 11 Konstantin Tokarev 2020-03-02 08:30:36 PST
Is it really correct to have such a quirk specifically for Google Docs? Any other web application can be potentially broken, as they may rely on Cache-Control headers to work properly in any navigation.
Comment 12 Chris Dumez 2020-03-02 08:36:25 PST
(In reply to Konstantin Tokarev from comment #11)
> Is it really correct to have such a quirk specifically for Google Docs? Any
> other web application can be potentially broken, as they may rely on
> Cache-Control headers to work properly in any navigation.

Cache-Control is about the HTTP disk cache, and works. There is no documented impact of the Cache-Control header on the back/forward cache.
Comment 13 Konstantin Tokarev 2020-03-02 08:44:16 PST
It seems to me that RFC 7234 doesn't make a difference between disk and memory caches. And CachedResourceLoader (rightfully) takes them into account, though it's not a disk cache.
Comment 14 Konstantin Tokarev 2020-03-02 08:56:42 PST
If there is a consensus that back/forward cache should be exempt from caching rules[*], IMHO it needs to be codified somewhere in Web Platform standards so that authors could design their pages accordingly.

[*]given that Google product doesn't assume this it seems to me there isn't)
Comment 15 Ryosuke Niwa 2020-03-02 23:18:46 PST
(In reply to Konstantin Tokarev from comment #14)
> If there is a consensus that back/forward cache should be exempt from
> caching rules[*], IMHO it needs to be codified somewhere in Web Platform
> standards so that authors could design their pages accordingly.
> 
> [*]given that Google product doesn't assume this it seems to me there isn't)

Back/Forward cache isn't like a "cache". When a page is put into back/forward cache, all page's states are still here. It's as if the page never navigated away. So it's not really a cache in the sense of the browser saving sub-resources & re-loading a web page using those cached resources. For web pages, it behaves as if the user hadn't navigated away / never been closed.