OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>HTTP Cache - Vary</title> |
| 6 <meta name="help" href="https://fetch.spec.whatwg.org/#request"> |
| 7 <script src="/resources/testharness.js"></script> |
| 8 <script src="/resources/testharnessreport.js"></script> |
| 9 <script src="/common/utils.js"></script> |
| 10 <script src="/common/get-host-info.sub.js"></script> |
| 11 <script src="http-cache.js"></script> |
| 12 </head> |
| 13 <body> |
| 14 <script> |
| 15 var tests = [ |
| 16 { |
| 17 name: 'HTTP cache reuses Vary response when request matches.', |
| 18 requests: [ |
| 19 { |
| 20 request_headers: [ |
| 21 ["Foo", "1"] |
| 22 ], |
| 23 response_headers: [ |
| 24 ["Expires", http_date(5000)], |
| 25 ["Last-Modified", http_date(-3000)], |
| 26 ["Vary", "Foo"] |
| 27 ] |
| 28 }, |
| 29 { |
| 30 request_headers: [ |
| 31 ["Foo", "1"] |
| 32 ], |
| 33 expected_type: "cached" |
| 34 } |
| 35 ] |
| 36 }, |
| 37 { |
| 38 name: "HTTP cache doesn't use Vary response when request doesn't match."
, |
| 39 requests: [ |
| 40 { |
| 41 request_headers: [ |
| 42 ["Foo", "1"] |
| 43 ], |
| 44 response_headers: [ |
| 45 ["Expires", http_date(5000)], |
| 46 ["Last-Modified", http_date(-3000)], |
| 47 ["Vary", "Foo"] |
| 48 ] |
| 49 }, |
| 50 { |
| 51 request_headers: [ |
| 52 ["Foo", "2"] |
| 53 ], |
| 54 expected_type: "not_cached" |
| 55 } |
| 56 ] |
| 57 }, |
| 58 { |
| 59 name: "HTTP cache doesn't use Vary response when request omits variant h
eader.", |
| 60 requests: [ |
| 61 { |
| 62 request_headers: [ |
| 63 ["Foo", "1"] |
| 64 ], |
| 65 response_headers: [ |
| 66 ["Expires", http_date(5000)], |
| 67 ["Last-Modified", http_date(-3000)], |
| 68 ["Vary", "Foo"] |
| 69 ] |
| 70 }, |
| 71 { |
| 72 expected_type: "not_cached" |
| 73 } |
| 74 ] |
| 75 }, |
| 76 { |
| 77 name: "HTTP cache doesn't invalidate existing Vary response.", |
| 78 requests: [ |
| 79 { |
| 80 request_headers: [ |
| 81 ["Foo", "1"] |
| 82 ], |
| 83 response_headers: [ |
| 84 ["Expires", http_date(5000)], |
| 85 ["Last-Modified", http_date(-3000)], |
| 86 ["Vary", "Foo"] |
| 87 ], |
| 88 response_body: http_content('foo_1') |
| 89 }, |
| 90 { |
| 91 request_headers: [ |
| 92 ["Foo", "2"] |
| 93 ], |
| 94 response_headers: [ |
| 95 ["Expires", http_date(5000)], |
| 96 ["Last-Modified", http_date(-3000)], |
| 97 ["Vary", "Foo"] |
| 98 ], |
| 99 expected_type: "not_cached", |
| 100 response_body: http_content('foo_2'), |
| 101 }, |
| 102 { |
| 103 request_headers: [ |
| 104 ["Foo", "1"] |
| 105 ], |
| 106 expected_type: "cached" |
| 107 } |
| 108 ] |
| 109 }, |
| 110 { |
| 111 name: "HTTP cache doesn't pay attention to headers not listed in Vary.", |
| 112 requests: [ |
| 113 { |
| 114 request_headers: [ |
| 115 ["Foo", "1"], |
| 116 ["Other", "2"] |
| 117 ], |
| 118 response_headers: [ |
| 119 ["Expires", http_date(5000)], |
| 120 ["Last-Modified", http_date(-3000)], |
| 121 ["Vary", "Foo"] |
| 122 ], |
| 123 }, |
| 124 { |
| 125 request_headers: [ |
| 126 ["Foo", "1"], |
| 127 ["Other", "3"] |
| 128 ], |
| 129 expected_type: "cached", |
| 130 } |
| 131 ] |
| 132 }, |
| 133 { |
| 134 name: 'HTTP cache reuses two-way Vary response when request matches.', |
| 135 requests: [ |
| 136 { |
| 137 request_headers: [ |
| 138 ["Foo", "1"], |
| 139 ["Bar", "abc"] |
| 140 ], |
| 141 response_headers: [ |
| 142 ["Expires", http_date(5000)], |
| 143 ["Last-Modified", http_date(-3000)], |
| 144 ["Vary", "Foo, Bar"] |
| 145 ] |
| 146 }, |
| 147 { |
| 148 request_headers: [ |
| 149 ["Foo", "1"], |
| 150 ["Bar", "abc"] |
| 151 ], |
| 152 expected_type: "cached" |
| 153 } |
| 154 ] |
| 155 }, |
| 156 { |
| 157 name: "HTTP cache doesn't use two-way Vary response when request doesn't
match.", |
| 158 requests: [ |
| 159 { |
| 160 request_headers: [ |
| 161 ["Foo", "1"], |
| 162 ["Bar", "abc"] |
| 163 ], |
| 164 response_headers: [ |
| 165 ["Expires", http_date(5000)], |
| 166 ["Last-Modified", http_date(-3000)], |
| 167 ["Vary", "Foo, Bar"] |
| 168 ] |
| 169 }, |
| 170 { |
| 171 request_headers: [ |
| 172 ["Foo", "2"], |
| 173 ["Bar", "abc"] |
| 174 ], |
| 175 expected_type: "not_cached" |
| 176 } |
| 177 ] |
| 178 }, |
| 179 { |
| 180 name: "HTTP cache doesn't use two-way Vary response when request omits v
ariant header.", |
| 181 requests: [ |
| 182 { |
| 183 request_headers: [ |
| 184 ["Foo", "1"] |
| 185 ], |
| 186 response_headers: [ |
| 187 ["Expires", http_date(5000)], |
| 188 ["Last-Modified", http_date(-3000)], |
| 189 ["Vary", "Foo, Bar"] |
| 190 ] |
| 191 }, |
| 192 { |
| 193 expected_type: "not_cached" |
| 194 } |
| 195 ] |
| 196 }, |
| 197 { |
| 198 name: 'HTTP cache reuses three-way Vary response when request matches.', |
| 199 requests: [ |
| 200 { |
| 201 request_headers: [ |
| 202 ["Foo", "1"], |
| 203 ["Bar", "abc"], |
| 204 ["Baz", "789"] |
| 205 ], |
| 206 response_headers: [ |
| 207 ["Expires", http_date(5000)], |
| 208 ["Last-Modified", http_date(-3000)], |
| 209 ["Vary", "Foo, Bar, Baz"] |
| 210 ] |
| 211 }, |
| 212 { |
| 213 request_headers: [ |
| 214 ["Foo", "1"], |
| 215 ["Bar", "abc"], |
| 216 ["Baz", "789"] |
| 217 ], |
| 218 expected_type: "cached" |
| 219 } |
| 220 ] |
| 221 }, |
| 222 { |
| 223 name: "HTTP cache doesn't use three-way Vary response when request doesn
't match.", |
| 224 requests: [ |
| 225 { |
| 226 request_headers: [ |
| 227 ["Foo", "1"], |
| 228 ["Bar", "abc"], |
| 229 ["Baz", "789"] |
| 230 ], |
| 231 response_headers: [ |
| 232 ["Expires", http_date(5000)], |
| 233 ["Last-Modified", http_date(-3000)], |
| 234 ["Vary", "Foo, Bar, Baz"] |
| 235 ] |
| 236 }, |
| 237 { |
| 238 request_headers: [ |
| 239 ["Foo", "2"], |
| 240 ["Bar", "abc"], |
| 241 ["Baz", "789"] |
| 242 ], |
| 243 expected_type: "not_cached" |
| 244 } |
| 245 ] |
| 246 }, |
| 247 { |
| 248 name: "HTTP cache doesn't use three-way Vary response when request omits
variant header.", |
| 249 requests: [ |
| 250 { |
| 251 request_headers: [ |
| 252 ["Foo", "1"], |
| 253 ["Baz", "789"] |
| 254 ], |
| 255 response_headers: [ |
| 256 ["Expires", http_date(5000)], |
| 257 ["Last-Modified", http_date(-3000)], |
| 258 ["Vary", "Foo, Bar, Baz"] |
| 259 ] |
| 260 }, |
| 261 { |
| 262 expected_type: "not_cached" |
| 263 } |
| 264 ] |
| 265 } |
| 266 ]; |
| 267 run_tests(tests); |
| 268 </script> |
| 269 </body> |
| 270 </html> |
OLD | NEW |