REGRESSION (XHR Caching): Uncacheable responses sent by Rails through Apache...
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2012 20:57:10 +0000 (20:57 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Apr 2012 20:57:10 +0000 (20:57 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=83925
        <rdar://problem/11231790>

        Reviewed by Antti Koivisto.

        Added subtests to http/tests/cache/subresource-expiration-2.html.

        * platform/network/ResourceResponseBase.cpp:
        (WebCore::ResourceResponseBase::parseCacheControlDirectives): Honor first max-age
        instead of the last. New behavior matches both Firefox and IE.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114165 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/cache/subresource-expiration-2-expected.txt
LayoutTests/http/tests/cache/subresource-expiration-2.html
Source/WebCore/ChangeLog
Source/WebCore/platform/network/ResourceResponseBase.cpp

index b14a4e6..2695af2 100644 (file)
@@ -1,3 +1,15 @@
+2012-04-13  Alexey Proskuryakov  <ap@apple.com>
+
+        REGRESSION (XHR Caching): Uncacheable responses sent by Rails through Apache are cached
+        https://bugs.webkit.org/show_bug.cgi?id=83925
+        <rdar://problem/11231790>
+
+        Reviewed by Antti Koivisto.
+
+        * http/tests/cache/subresource-expiration-2-expected.txt:
+        * http/tests/cache/subresource-expiration-2.html:
+        Added tests for multiple max-age directives.
+
 2012-04-13  Rob Flack  <flackr@chromium.org>
 
         Chromium: Should enable -webkit-image-set
index 070bd4e..789295e 100644 (file)
@@ -4,6 +4,8 @@ Cache-control: max-age=10, must-revalidate; (result=Cached expected=Cached) PASS
 Age: 100; Cache-control: max-age=10; (result=Uncached expected=Uncached) PASS
 Age: 1; Cache-control: max-age=10; (result=Cached expected=Cached) PASS
 Cache-control: max-age=10; Pragma: no-cache; (result=Uncached expected=Uncached) PASS
+Cache-control: max-age=0, private, must-revalidate, max-age=60; (result=Uncached expected=Uncached) PASS
+Cache-control: max-age=60, private, must-revalidate, max-age=0; (result=Cached expected=Cached) PASS
 Expires: [now-10s]; Cache-control: max-age=10; (result=Cached expected=Cached) PASS
 Expires: [now+10s]; Cache-control: max-age=0; (result=Uncached expected=Uncached) PASS
 Last-modified: [now-3600s]; [delay=1.5s] (result=Cached expected=Cached) PASS
index cea82c1..7975600 100644 (file)
@@ -44,6 +44,18 @@ tests = [
     },
     {
         testHeaders: {
+            'Cache-control': 'max-age=0, private, must-revalidate, max-age=60',
+        },
+        expectedResult: 'Uncached',
+    },
+    {
+        testHeaders: {
+            'Cache-control': 'max-age=60, private, must-revalidate, max-age=0',
+        },
+        expectedResult: 'Cached',
+    },
+    {
+        testHeaders: {
             'Expires': '[now-10s]',
             'Cache-control': 'max-age=10'
         },
index 15e9e65..087797e 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-13  Alexey Proskuryakov  <ap@apple.com>
+
+        REGRESSION (XHR Caching): Uncacheable responses sent by Rails through Apache are cached
+        https://bugs.webkit.org/show_bug.cgi?id=83925
+        <rdar://problem/11231790>
+
+        Reviewed by Antti Koivisto.
+
+        Added subtests to http/tests/cache/subresource-expiration-2.html.
+
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::parseCacheControlDirectives): Honor first max-age
+        instead of the last. New behavior matches both Firefox and IE.
+
 2012-04-13  James Robinson  <jamesr@chromium.org>
 
         [chromium] Move WebVideoFrame into Platform and remove WebCore::VideoFrameChromium wrapper API
index 67d8203..1247843 100644 (file)
@@ -339,6 +339,10 @@ void ResourceResponseBase::parseCacheControlDirectives() const
             else if (equalIgnoringCase(directives[i].first, mustRevalidateDirective))
                 m_cacheControlContainsMustRevalidate = true;
             else if (equalIgnoringCase(directives[i].first, maxAgeDirective)) {
+                if (!isnan(m_cacheControlMaxAge)) {
+                    // First max-age directive wins if there are multiple ones.
+                    continue;
+                }
                 bool ok;
                 double maxAge = directives[i].second.toDouble(&ok);
                 if (ok)