<?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>58797</bug_id>
          
          <creation_ts>2011-04-18 10:55:56 -0700</creation_ts>
          <short_desc>Vary header and Conditional HTTP request error</short_desc>
          <delta_ts>2024-07-24 06:22:56 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>OS X 10.6</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="Paul Sadauskas">psadauskas</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>aestes</cc>
    
    <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>fishd</cc>
    
    <cc>jaffathecake</cc>
    
    <cc>japhet</cc>
    
    <cc>koivisto</cc>
    
    <cc>mathias</cc>
    
    <cc>m_finkel</cc>
    
    <cc>m.goleb+bugzilla</cc>
    
    <cc>mnot</cc>
    
    <cc>psolanki</cc>
    
    <cc>tonyg</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>387867</commentid>
    <comment_count>0</comment_count>
    <who name="Paul Sadauskas">psadauskas</who>
    <bug_when>2011-04-18 10:55:56 -0700</bug_when>
    <thetext>What steps will reproduce the problem?

1. Have a resource that accepts multiple representations (json/html), includes `Accept` in the `Vary` response header, and handles conditional requests with `If-Modified-Since`
2. Have Safari visit the resource, first with a modified Accept header (json), then with its normal header.

What is the expected result?

A 200 OK response from the server for the second request.

What happens instead?

A 304 Not Modified response to the second request, because Safari includes both `If-Modified-Since` and `If-None-Match` in the request, even though the `Vary: Accept` response header indicates the altered Accept header should result in a different response. The end-user effect of this is that Safari downloads the json file on the second request, rather than rendering the html.

Please provide any additional information below. 

tcpdump output of Chrome/Safari vs Firefox: https://gist.github.com/925714

Cross-posted to the chromium bug tracker: http://code.google.com/p/chromium/issues/detail?id=79758</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>388050</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2011-04-18 14:43:57 -0700</bug_when>
    <thetext>Sounds like one of the many consequences of keying WebCore memory cache off URL alone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>388586</commentid>
    <comment_count>2</comment_count>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2011-04-19 10:41:30 -0700</bug_when>
    <thetext>Chromium&apos;s network stack implements Vary header support by computing a hash of the request headers subset and storing that hash in the cache meta data.  Before reusing a cache entry, the hash of the current set of request headers is computed and then that is compared against the stored value.

You can see the code for this here:
http://src.chromium.org/viewvc/chrome/trunk/src/net/http/http_vary_data.cc?view=markup

It is important to note that if we are caching redirects (I don&apos;t think WebCore&apos;s cache does so), that we should always assume that a cached redirect has an implicit &quot;Vary: Cookie&quot; header for compat with the web.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>986833</commentid>
    <comment_count>3</comment_count>
    <who name="Jake Archibald">jaffathecake</who>
    <bug_when>2014-03-04 08:58:36 -0800</bug_when>
    <thetext>Seeing this issue at http://jakearchibald.com/2014/browser-cache-vary-broken/#changing-api-response-type-based-on-accept

However, in this case the response has a max-age, so the wrong content comes straight from the cache.

Although Safari fails when varying on &quot;Accept&quot;, it seems to get it right when varying on &quot;Accept-Language&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>987230</commentid>
    <comment_count>4</comment_count>
    <who name="Jake Archibald">jaffathecake</who>
    <bug_when>2014-03-05 06:05:49 -0800</bug_when>
    <thetext>Here&apos;s the bug, https://github.com/WebKit/webkit/blob/e025cae9b34b75b236b30a614fa43cd39337fe65/Source/WebCore/loader/cache/CachedRawResource.cpp#L206 - &quot;m_headers.add(&quot;Accept&quot;);&quot; shouldn&apos;t be there.

(based on https://codereview.chromium.org/85623006)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>987502</commentid>
    <comment_count>5</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2014-03-05 19:22:55 -0800</bug_when>
    <thetext>&lt;rdar://problem/16244607&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1384483</commentid>
    <comment_count>6</comment_count>
    <who name="Michał Gołębiowski-Owczarek">m.goleb+bugzilla</who>
    <bug_when>2017-12-22 09:28:21 -0800</bug_when>
    <thetext>Any updates after 3.5 years? This has just bit me in a project that works correctly everywhere (Chrome, Firefox, Edge) except in Safari.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2007226</commentid>
    <comment_count>7</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2024-01-24 08:33:26 -0800</bug_when>
    <thetext>(In reply to Jake Archibald from comment #4)
&gt; Here&apos;s the bug,
&gt; https://github.com/WebKit/webkit/blob/
&gt; e025cae9b34b75b236b30a614fa43cd39337fe65/Source/WebCore/loader/cache/
&gt; CachedRawResource.cpp#L206 - &quot;m_headers.add(&quot;Accept&quot;);&quot; shouldn&apos;t be there.
&gt; 
&gt; (based on https://codereview.chromium.org/85623006)

It seems to be now this in WebKit Source:

https://searchfox.org/wubkat/rev/ec4f4923b19d0ed56921d6b5b0aadb69ada735eb/Source/WebCore/loader/cache/CachedRawResource.cpp#290</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>