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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>147022</bug_id>
          
          <creation_ts>2015-07-16 15:17:55 -0700</creation_ts>
          <short_desc>Cached XHR requests are not shown in the web inspector</short_desc>
          <delta_ts>2026-01-12 09:08:46 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sam Weinig">sam</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>andre</cc>
    
    <cc>graouts</cc>
    
    <cc>inspector-bugzilla-changes</cc>
    
    <cc>joepeck</cc>
    
    <cc>jonowells</cc>
    
    <cc>koivisto</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1109998</commentid>
    <comment_count>0</comment_count>
      <attachid>256932</attachid>
    <who name="Sam Weinig">sam</who>
    <bug_when>2015-07-16 15:17:55 -0700</bug_when>
    <thetext>Created attachment 256932
Test Case

As reported in http://www.raymondcamden.com/2015/07/16/safari-and-http-caching, cached XHRs are not shown in the web inspector. Test case attached.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1110000</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2015-07-16 15:18:21 -0700</bug_when>
    <thetext>&lt;rdar://problem/21864126&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1110001</commentid>
    <comment_count>2</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2015-07-16 15:18:27 -0700</bug_when>
    <thetext>&lt;rdar://problem/21859864&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1110005</commentid>
    <comment_count>3</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2015-07-16 15:26:20 -0700</bug_when>
    <thetext>The Web Inspector frontend is only told about one requestWillBeSent from the backend (followed up by its responseReceived/dataReceived/loadingFinished updates):

    backend: {
        &quot;method&quot;: &quot;Network.requestWillBeSent&quot;,
        &quot;params&quot;: {
            &quot;requestId&quot;: &quot;0.15&quot;,
            &quot;frameId&quot;: &quot;0.1&quot;,
            &quot;loaderId&quot;: &quot;0.5&quot;,
            &quot;documentURL&quot;: &quot;file:///Volumes/Data/Users/pecoraro/Desktop/cache-bug.html&quot;,
            &quot;request&quot;: {
                &quot;url&quot;: &quot;http://api.randomuser.me/&quot;,
                &quot;method&quot;: &quot;GET&quot;,
                &quot;headers&quot;: {
                    &quot;Accept&quot;: &quot;application/json, text/javascript, */*; q=0.01&quot;,
                    &quot;User-Agent&quot;: &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/602.1.1 (KHTML, like Gecko) Version/9.0 Safari/601.1.41&quot;,
                    &quot;Cache-Control&quot;: &quot;max-age=0&quot;
                }
            },
            &quot;timestamp&quot;: 0.045744980983727146,
            &quot;initiator&quot;: { ... }
            &quot;type&quot;: &quot;XHR&quot;
        }
    }

So from the appearance of the frontend only 1 request was sent. That may in fact be what the engine is doing. The frontend should at least show that &gt;1 XHR was initiated for the same URL, even if only 1 request was actually sent and they are sharing it. It would likely share a lot of timing information.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1290708</commentid>
    <comment_count>4</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2017-03-23 19:39:07 -0700</bug_when>
    <thetext>In this test (as of today) Safari makes 2 requests. The first has a unique response, the second is shared by the remaining 9 XHRs. This behavior is equivalent to 10 &lt;img src=&quot;...&quot;&gt; for the same URL. In that case, we also only see a single Resource in the Network Tab and Resources Tab.

In both cases, WebKit is making a network load, and while that load is in flight new requests are made for the same resource and we&apos;ve determined that we can use the existing load&apos;s results.

Debugging with Antti we saw that we fall under this case in CachedResourceLoader::determineRevalidationPolicy:

&gt;    if (existingResource-&gt;isLoading()) {
&gt;        ...
&gt;        // For cached subresources that are still loading we ignore the cache policy.
&gt;        return Use;
&gt;    }

The original article makes the point that:

&gt; Looking at this, you can see Safari made one network request, which I
&gt; suppose makes sense, but here is what ticks me off. Nowhere in this
&gt; panel is any indication that it simply ignored my Ajax calls and used
&gt; a cache result.

This is a fair point. We seem to be looking at two cases concerning the Memory Cache:

    1. A Request for a resource uses a response fully loaded response from our Memory Cache
      =&gt; Web Inspector shows this as a resource loaded from the Memory Cache

    2. A Request for a resource uses an ongoing request from our Memory Cache
      =&gt; Web Inspector is not informed about it

This is case (2). Possible solutions:

    Approach 1: Inform Web Inspector about Cache Hits for not yet loaded requests
      =&gt; We would see many XHR resources and Image resources for the above tests
      * We could show 10 network requests, with 1 a real load and 9 as memory cache.
      * We could do something like show the # of clients an individual response satisfied
        when it completed so we could show one load in the UI but also show that the load
        satisfied (10) clients. That begs the question of who the clients / initiators were.
   
    Approach 2: Do nothing, change XHR loading policy to match other browsers
      =&gt; Issue multiple XHR requests, which seems like what the developer expected anyways
      * Funnily enough this would match other browsers the most. Other browsers have the
        same behavior as Safari for the &lt;img&gt; case. They are just different in the XHR
        case because they send multiple requests.

    Approach 3: Special Cases
      =&gt; We could treat some subresource types as special to show ALL requests and others
      * This is essentially what other browsers have done at the engine level. Treating
        XHR loads different from Image loads, otherwise they would be seeing the same.

I don&apos;t yet have a strong opinion on whether we take approach 1 or 2. Either way it raises the point that if we want to show all of the initiators / requestors of a particular load, that if there are multiple initiators we might want to show them all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1290711</commentid>
    <comment_count>5</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2017-03-23 19:42:54 -0700</bug_when>
    <thetext>I should point out the &lt;img&gt; test I&apos;m testing that shows other browsers have the same kind of behavior is just a page like:

    &lt;img src=&quot;foo.png&quot;&gt;
    &lt;img src=&quot;foo.png&quot;&gt;
    &lt;img src=&quot;foo.png&quot;&gt;
    ...

All browsers I&apos;ve tested only show a single resource in their Network tabs for this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1302421</commentid>
    <comment_count>6</comment_count>
    <who name="Sam Weinig">sam</who>
    <bug_when>2017-04-27 17:38:51 -0700</bug_when>
    <thetext>(In reply to Joseph Pecoraro from comment #5)
&gt; I should point out the &lt;img&gt; test I&apos;m testing that shows other browsers have
&gt; the same kind of behavior is just a page like:
&gt; 
&gt;     &lt;img src=&quot;foo.png&quot;&gt;
&gt;     &lt;img src=&quot;foo.png&quot;&gt;
&gt;     &lt;img src=&quot;foo.png&quot;&gt;
&gt;     ...
&gt; 
&gt; All browsers I&apos;ve tested only show a single resource in their Network tabs
&gt; for this.

Oh how I hate to suggest a switch, but it might be nice to have someway to see all resource requests, even ones that hit the cache, for times when that information would be useful.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>256932</attachid>
            <date>2015-07-16 15:17:55 -0700</date>
            <delta_ts>2015-07-16 15:17:55 -0700</delta_ts>
            <desc>Test Case</desc>
            <filename>cache-bug.html</filename>
            <type>text/html</type>
            <size>618</size>
            <attacher name="Sam Weinig">sam</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+Cgo8aHRtbD4KPGhlYWQ+CiAgICA8c2NyaXB0IHNyYz0iaHR0cHM6Ly9h
amF4Lmdvb2dsZWFwaXMuY29tL2FqYXgvbGlicy9qcXVlcnkvMS4xMS4zL2pxdWVyeS5taW4uanMi
Pjwvc2NyaXB0PgogICAgPHNjcmlwdD4KICAgICAgICBmdW5jdGlvbiBkb1Rlc3QoKQogICAgICAg
IHsKICAgICAgICAgICAgZm9yKHZhciBpPTA7aTwxMDtpKyspIHsKICAgICAgICAgICAgICAgICQu
YWpheCh7CiAgICAgICAgICAgICAgICAgIHVybDogJ2h0dHA6Ly9hcGkucmFuZG9tdXNlci5tZS8n
LAogICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLAogICAgICAgICAgICAgICAgICBz
dWNjZXNzOiBmdW5jdGlvbihkYXRhKXsKICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhK
U09OLnN0cmluZ2lmeShkYXRhLnJlc3VsdHNbMF0udXNlci5uYW1lKSk7CiAgICAgICAgICAgICAg
ICAgIH0KICAgICAgICAgICAgICAgIH0pOwoKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAg
ICAKICAgICAgICB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcignbG9hZCcsIGRvVGVzdCwgZmFsc2Up
OwogICAgPC9zY3JpcHQ+CjwvaGVhZD4KPGJvZHk+Cgo8L2JvZHk+CjwvaHRtbD4K
</data>

          </attachment>
      

    </bug>

</bugzilla>