You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Privacy] Time limit on retaining beacons for bfcache'd pages #3
My understanding is that with the Declarative Beacon API, if a page is kept in the bfcache for an extended period of time, it's still eligible to send the beacon once the page is evicted from the bfcache, which might be a long time after the user has navigated away from the page.
Would it be possible to instead send the beacon for bfcache'd pages after they've been in the bfcache for a minute or so? I think the page would want to check when waking from the bfcache to see if the beacon was already sent or not (by checking the state field of the beacon from the explainer) -- if it's already sent, the page may want to create a new beacon (at its choice).
I think that this is what the pageHideTimeout setting is for -- pageHide is emitted when the page enters the bfcache, and that should start a timer for any beacons with pageHideTimeout set. If they aren't restored from cache by the time that timer expires, they will be sent at that time (rather than waiting until eviction)
For frozen pages that are never unfrozen, this should happen either when the frozen page is removed from memory (BFCache eviction), or after a developer-specified timeout (using the 'pageHideTimeout' described below).
I think the idea is the beacon is sent for whichever event happens first of the two? But, if the site doesn't set pageHideTimeout, what is the behavior? Also, can pageHideTimeout be arbitrarily large?
The pageHideTimeout behavior sounds like the behavior we want, but I think the explainer and spec should be updated to give default and maximum pageHideTimeout values to prevent sending beacons at bfcache eviction at some point long after the user has left the page.
I think the idea is the beacon is sent for whichever event happens first of the two?
Yes
But, if the site doesn't set pageHideTimeout, what is the behavior?
The default behavior is specified in the pageHideTimeout section, i.e. If this is null when the page is hidden, the beacon will be sent on document discard (including eviction from the BFCache)
Also, can pageHideTimeout be arbitrarily large?
It is possible as there is currently no maximum.
maximum pageHideTimeout values to prevent sending beacons at bfcache eviction at some point long after the user has left the page.
I think users should specify pageHideTimeout if they don't want to wait too long.
I think users should specify pageHideTimeout if they don't want to wait too long.
I agree, but for privacy, I think there should be a limit (imposed by the browser) on how long this duration can be that the web content cannot override. I think the spec and explainer should require such limits.
That sounds like a second issue, @caraitto (but correct me if I'm wrong)
The first issue I see is one of developer ergonomics. In order to have beacons sent in a timely manner, there should be a way to ensure that they are sent a short time after entering the bfcache. We have that, and it's pageHideTimeout. My understanding is that if that is set, and a page enters the cache, then one of three things can happen: (Whichever happens first wins)
If the page is restored from the cache, the beacon is cancelled.
If the page is evicted from the cache (which browsers will do after a short timeout; the cache is fairly short-lived in current imlementations), then the beacon is sent.
If the page is still in the cache after pageHideTimeout ms, then the beacon will be sent (and will be in a 'sent' state if the page is subsequently restored)
The second issue you raise is a privacy concern, which I think is motivated by a "what if browser's didn't do that" question around the second point above. Currently there is a time limit set by browsers, which web content can't override (Chrome, for instance, has a 3 minute timer). But what if future browsers keep pages in the bfcache for an arbitrarily long time, and also developers don't choose to set a timeout on their own. Should we protect developers from that situation?
I feel that there could be an implementation note, certainly, that there should be some reasonable limit, if the user agent is capable of retaining cache entries indefinitely, and it warrants a section in the privacy section of the spec. I don't know if there's sufficient alignment between cache implementations to specify yet exactly what a hard limit needs to be.
I feel that there could be an implementation note, certainly, that there should be some reasonable limit, if the user agent is capable of retaining cache entries indefinitely, and it warrants a section in the privacy section of the spec.
Yep, I think that's basically what I'd like to see -- I'll go ahead and send a PR (#5). I think 3 minutes might be OK, but I'd be less comfortable if it was over 10 minutes.
Activity
caraitto commentedon Jun 27, 2022
Hi, friendly ping?
clelland commentedon Jun 27, 2022
I think that this is what the
pageHideTimeoutsetting is for --pageHideis emitted when the page enters the bfcache, and that should start a timer for any beacons withpageHideTimeoutset. If they aren't restored from cache by the time that timer expires, they will be sent at that time (rather than waiting until eviction)caraitto commentedon Jun 27, 2022
The explainer says:
I think the idea is the beacon is sent for whichever event happens first of the two? But, if the site doesn't set
pageHideTimeout, what is the behavior? Also, canpageHideTimeoutbe arbitrarily large?The
pageHideTimeoutbehavior sounds like the behavior we want, but I think the explainer and spec should be updated to give default and maximumpageHideTimeoutvalues to prevent sending beacons at bfcache eviction at some point long after the user has left the page.mingyc commentedon Jun 28, 2022
Yes
The default behavior is specified in the
pageHideTimeoutsection, i.e. If this is null when the page is hidden, the beacon will be sent on document discard (including eviction from the BFCache)It is possible as there is currently no maximum.
I think users should specify pageHideTimeout if they don't want to wait too long.
caraitto commentedon Jun 28, 2022
I agree, but for privacy, I think there should be a limit (imposed by the browser) on how long this duration can be that the web content cannot override. I think the spec and explainer should require such limits.
clelland commentedon Jun 28, 2022
That sounds like a second issue, @caraitto (but correct me if I'm wrong)
The first issue I see is one of developer ergonomics. In order to have beacons sent in a timely manner, there should be a way to ensure that they are sent a short time after entering the bfcache. We have that, and it's
pageHideTimeout. My understanding is that if that is set, and a page enters the cache, then one of three things can happen: (Whichever happens first wins)pageHideTimeoutms, then the beacon will be sent (and will be in a 'sent' state if the page is subsequently restored)The second issue you raise is a privacy concern, which I think is motivated by a "what if browser's didn't do that" question around the second point above. Currently there is a time limit set by browsers, which web content can't override (Chrome, for instance, has a 3 minute timer). But what if future browsers keep pages in the bfcache for an arbitrarily long time, and also developers don't choose to set a timeout on their own. Should we protect developers from that situation?
I feel that there could be an implementation note, certainly, that there should be some reasonable limit, if the user agent is capable of retaining cache entries indefinitely, and it warrants a section in the privacy section of the spec. I don't know if there's sufficient alignment between cache implementations to specify yet exactly what a hard limit needs to be.
Add a bfcache time limit to privacy section.
caraitto commentedon Jun 29, 2022
Yep, I think that's basically what I'd like to see -- I'll go ahead and send a PR (#5). I think 3 minutes might be OK, but I'd be less comfortable if it was over 10 minutes.
Add a bfcache time limit to privacy section
mingyc commentedon Aug 1, 2022
This was re-discussed in #16 (comment):
Maybe we should re-consider how long timeout limit should be.
Update Privacy section to clarify network change (#29)
Lower the bfcache limit to 10 min.
79 remaining items
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…
[fetch-later] Force sending when BackgroundSync permission is off
Revert "[fetch-later] Force sending when BackgroundSync permission is…
Bug 1798615 [wpt PR 36775] - [beacon-api] Ensure beacons sending on n…
Bug 1856331 [wpt PR 42276] - [fetch-later] Force sending when Backgro…
Bug 1856459 [wpt PR 42294] - Revert "[fetch-later] Force sending when…
Bug 1856459 [wpt PR 42294] - Revert "[fetch-later] Force sending when…
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…
Bug 1856528 [wpt PR 42306] - Reland "[fetch-later] Force sending when…