<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>12651</bug_id>
          
          <creation_ts>2011-05-12 18:43:50 +0000</creation_ts>
          <short_desc>More things should set salvageable to false: XHR, plugins</short_desc>
          <delta_ts>2011-09-29 18:51:26 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#unloading-documents</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>ap</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>ian</cc>
    
    <cc>jonas</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>zcorpan</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>48491</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-05-12 18:43:50 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/complete/history.html
Section: http://www.whatwg.org/specs/web-apps/current-work/#unloading-documents

Comment:
More things should set salvageable. Like XHR. See
&lt;http://trac.webkit.org/browser/trunk/Source/WebCore/history/PageCache.cpp&gt;
for relevant code in safari (thanks ap)

Posted from: 85.227.158.3 by simonp@opera.com
User agent: Opera/9.80 (Macintosh; Intel Mac OS X 10.5.8; U; en) Presto/2.8.131 Version/11.10</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>48492</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-05-12 18:50:08 +0000</bug_when>
    <thetext>Obviously, not all WebKit&apos;s reasons to prevent page caching need to be standardized, and some of them probably can&apos;t be easily deconstructed.

A few cases are hiding under canSuspendActiveDOMObjects(), such as Workers and running IDBTransactions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50218</commentid>
    <comment_count>2</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-06-24 10:40:57 +0000</bug_when>
    <thetext>Should this be defined in XMLHttpRequest?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50358</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Pieters">zcorpan</who>
    <bug_when>2011-06-27 07:35:14 +0000</bug_when>
    <thetext>It&apos;d make sense for the XHR spec to cover XHR&apos;s interaction here. But there are other things besides XHR.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53913</commentid>
    <comment_count>4</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:34:25 +0000</bug_when>
    <thetext>mass-move component to LC1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55269</commentid>
    <comment_count>5</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-17 04:17:18 +0000</bug_when>
    <thetext>I assume you mean &quot;more things should set salvageable _to false_&quot;.

I&apos;m happy to add more things, or add hooks for other specs if necessary (I think hooks already exist though).

The only case I could find from the source above that looked relevant is that we can&apos;t bfcache a page if anything in its browsing context involves a live plugin.

The other things didn&apos;t look like things we should add to the spec, though. For example, why would the use of shared workers affect it? Why would encrypted pages be affected?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55297</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-08-17 14:09:32 +0000</bug_when>
    <thetext>Gecko bfcaches pages with plug-ins and just stops/restarts the plug-in.  It&apos;s caused us a few compat issues, but not very many, and there&apos;s been work to provide a better stop/restart in NPAPI so that plug-ins can play nicely with bfcache.

So I don&apos;t think we should add plug-ins to the list of things that make pages not salvageable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>55606</commentid>
    <comment_count>7</comment_count>
    <who name="Jonas Sicking (Not reading bugmail)">jonas</who>
    <bug_when>2011-08-22 20:30:35 +0000</bug_when>
    <thetext>Gecko also doesn&apos;t have any XHR specific code. We do however prevent bfcaching of any page which has open network connections.

Potentially ideally we should exempt EventSource from this so network connections held open by a page using EventSource *doesn&apos;t* set salvageable to false.

But any other network connections, such as dynamically loaded &lt;img&gt; or XHR causes the salvageable flag to be false.

And for these purposes, &quot;network connections&quot; include connections to the filesystem. So a FileReader which is currently reading a Blob or File will also cause salvageable to be false.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57122</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-09-21 21:23:38 +0000</bug_when>
    <thetext>Why do you set salvageable to false if you&apos;ve got an open network connection up, rather than just finishing the download (especially if it&apos;s only been going for a few milliseconds)?

Note that the browser is always allowed to throw out a bfcached page; I could add some text saying that if a network connection is prematurely aborted then it should be thrown out, if you like.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57138</commentid>
    <comment_count>9</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-09-22 01:45:00 +0000</bug_when>
    <thetext>&gt; Why do you set salvageable to false if you&apos;ve got an open network connection
&gt; up, rather than just finishing the download

Several reasons:

1)  For just about every network connection, download completion needs to trigger an event handler, which is a really weird thing to do in an unloaded page.  This is certainly the case for XHR.

2)  At least in Gecko, the data structure tracking in-progress network access is attached to the WindowProxy (because you have to be able to treat a load as starting in one page but finishing in another).  So on page transition requests have to be canceled so as not to affect onload in the new page.

3)  Having unloaded pages consume network resources is very much contrary to user expectations.

&gt; (especially if it&apos;s only been going for a few milliseconds)?

I don&apos;t see why this is an &quot;especially&quot; or why it matters.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57518</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-09-29 18:51:26 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; 1)  For just about every network connection, download completion needs to
&gt; trigger an event handler, which is a really weird thing to do in an unloaded
&gt; page.  This is certainly the case for XHR.

The way the spec is written today, the task for that event would get queued, and the event loop skips tasks from documents that aren&apos;t active, so the event would fire once the document was made active again.


&gt; 2)  At least in Gecko, the data structure tracking in-progress network access
&gt; is attached to the WindowProxy (because you have to be able to treat a load as
&gt; starting in one page but finishing in another).  So on page transition 
&gt; requests have to be canceled so as not to affect onload in the new page.

Ok.


&gt; 3)  Having unloaded pages consume network resources is very much contrary to
&gt; user expectations.

Yeah, I completely agree that if the download is using up resources then it deserves to be dropped if it&apos;s not active.


&gt; &gt; (especially if it&apos;s only been going for a few milliseconds)?
&gt; 
&gt; I don&apos;t see why this is an &quot;especially&quot; or why it matters.

I figure some browsers will want the following model to work:

 - user is on a page.
 - every now and then, the page causes a very brief network request.
 - the user clicks a link on the page.
 - user then hits the back button.

If the user clicked the link while no network request was active, hitting the back button will be fast, because it&apos;ll be bfcached. But if a request _was_ active, then it&apos;ll be slow. The user can&apos;t tell the difference.


Anyway. Per spec, the browser is allowed to discard a document in the bfcache whenever it wants. I think we should only be aborting documents and setting their salvageable flag to false in cases where there is really no way that bfcache can work (e.g. when there&apos;s an unload event handler). We shouldn&apos;t be disallowing cases where implementation difficulties mean that it doesn&apos;t work today, but where one could imagine another browser, or the same browser after lots of work, doing it in a way that allowed bfcache.

(Note that one exception to this currently is that the spec requires document loads that are in-progress during a navigation to be aborted, regardless of whether it&apos;s truly necessary or not. I added that recently, because every browsers does it. Maybe it was a mistake, though.)


EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale: It doesn&apos;t seem any of the cases listed in this bug are cases where we cannot imagine a browser successfully using bfcache, so we shouldn&apos;t preclude it in those cases. I&apos;m happy to add cases if there are some that are actual problems in all cases.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>