OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>HTTP Cache - Freshness</title> |
| 6 <meta name="help" href="https://fetch.spec.whatwg.org/#request"> |
| 7 <meta name="timeout" content="long"> |
| 8 <script src="/resources/testharness.js"></script> |
| 9 <script src="/resources/testharnessreport.js"></script> |
| 10 <script src="/common/utils.js"></script> |
| 11 <script src="/common/get-host-info.sub.js"></script> |
| 12 <script src="http-cache.js"></script> |
| 13 </head> |
| 14 <body> |
| 15 <script> |
| 16 var tests = [ |
| 17 // response directives |
| 18 { |
| 19 name: 'HTTP cache reuses a response with a future Expires.', |
| 20 requests: [ |
| 21 { |
| 22 response_headers: [ |
| 23 ["Expires", http_date(30*24*60*60)] |
| 24 ] |
| 25 }, |
| 26 { |
| 27 expected_type: "cached", |
| 28 } |
| 29 ] |
| 30 }, |
| 31 { |
| 32 name: 'HTTP cache does not reuse a response with a past Expires.', |
| 33 requests: [ |
| 34 { |
| 35 response_headers: [ |
| 36 ["Expires", http_date(-30*24*60*60)] |
| 37 ] |
| 38 }, |
| 39 { |
| 40 expected_type: "not_cached", |
| 41 } |
| 42 ] |
| 43 }, |
| 44 { |
| 45 name: 'HTTP cache does not reuse a response with a present Expires.', |
| 46 requests: [ |
| 47 { |
| 48 response_headers: [ |
| 49 ["Expires", http_date(0)] |
| 50 ] |
| 51 }, |
| 52 { |
| 53 expected_type: "not_cached", |
| 54 } |
| 55 ] |
| 56 }, |
| 57 { |
| 58 name: 'HTTP cache does not reuse a response with an invalid Expires.', |
| 59 requests: [ |
| 60 { |
| 61 response_headers: [ |
| 62 ["Expires", "0"] |
| 63 ] |
| 64 }, |
| 65 { |
| 66 expected_type: "not_cached", |
| 67 } |
| 68 ] |
| 69 }, |
| 70 { |
| 71 name: 'HTTP cache reuses a response with positive Cache-Control: max-age
.', |
| 72 requests: [ |
| 73 { |
| 74 response_headers: [ |
| 75 ["Cache-Control", "max-age=3600"] |
| 76 ] |
| 77 }, |
| 78 { |
| 79 expected_type: "cached", |
| 80 } |
| 81 ] |
| 82 }, |
| 83 { |
| 84 name: 'HTTP cache does not reuse a response with Cache-Control: max-age=
0.', |
| 85 requests: [ |
| 86 { |
| 87 response_headers: [ |
| 88 ["Cache-Control", "max-age=0"] |
| 89 ] |
| 90 }, |
| 91 { |
| 92 expected_type: "not_cached", |
| 93 } |
| 94 ] |
| 95 }, |
| 96 { |
| 97 name: 'HTTP cache reuses a response with positive Cache-Control: max-age
and a past Expires.', |
| 98 requests: [ |
| 99 { |
| 100 response_headers: [ |
| 101 ["Cache-Control", "max-age=3600"], |
| 102 ['Expires', http_date(-10000)] |
| 103 ] |
| 104 }, |
| 105 { |
| 106 expected_type: "cached", |
| 107 } |
| 108 ] |
| 109 }, |
| 110 { |
| 111 name: 'HTTP cache reuses a response with positive Cache-Control: max-age
and an invalid Expires.', |
| 112 requests: [ |
| 113 { |
| 114 response_headers: [ |
| 115 ["Cache-Control", "max-age=3600"], |
| 116 ['Expires', '0'] |
| 117 ] |
| 118 }, |
| 119 { |
| 120 expected_type: "cached", |
| 121 } |
| 122 ] |
| 123 }, |
| 124 { |
| 125 name: 'HTTP cache does not reuse a response with Cache-Control: max-age=
0 and a future Expires.', |
| 126 requests: [ |
| 127 { |
| 128 response_headers: [ |
| 129 ["Cache-Control", "max-age=0"], |
| 130 ['Expires', http_date(10000)] |
| 131 ] |
| 132 }, |
| 133 { |
| 134 expected_type: "not_cached", |
| 135 } |
| 136 ] |
| 137 }, |
| 138 { |
| 139 name: 'HTTP cache does not prefer Cache-Control: s-maxage over Cache-Con
trol: max-age.', |
| 140 requests: [ |
| 141 { |
| 142 response_headers: [ |
| 143 ["Cache-Control", "max-age=1, s-maxage=3600"] |
| 144 ], |
| 145 pause_after: true, |
| 146 }, |
| 147 { |
| 148 expected_type: "not_cached", |
| 149 } |
| 150 ] |
| 151 }, |
| 152 { |
| 153 name: 'HTTP cache does not reuse a response when the Age header is great
er than its freshness lifetime.', |
| 154 requests: [ |
| 155 { |
| 156 response_headers: [ |
| 157 ["Cache-Control", "max-age=3600"], |
| 158 ["Age", "12000"] |
| 159 ], |
| 160 }, |
| 161 { |
| 162 expected_type: "not_cached", |
| 163 } |
| 164 ] |
| 165 }, |
| 166 { |
| 167 name: 'HTTP cache does not store a response with Cache-Control: no-store
.', |
| 168 requests: [ |
| 169 { |
| 170 response_headers: [ |
| 171 ["Cache-Control", "no-store"] |
| 172 ] |
| 173 }, |
| 174 { |
| 175 expected_type: "not_cached", |
| 176 } |
| 177 ] |
| 178 }, |
| 179 { |
| 180 name: 'HTTP cache does not store a response with Cache-Control: no-store
, even with max-age and Expires.', |
| 181 requests: [ |
| 182 { |
| 183 response_headers: [ |
| 184 ["Cache-Control", "max-age=10000, no-store"], |
| 185 ['Expires', http_date(10000)] |
| 186 ] |
| 187 }, |
| 188 { |
| 189 expected_type: "not_cached", |
| 190 } |
| 191 ] |
| 192 }, |
| 193 { |
| 194 name: 'HTTP cache stores a response with Cache-Control: no-cache, but re
validates upon use.', |
| 195 requests: [ |
| 196 { |
| 197 response_headers: [ |
| 198 ["Cache-Control", "no-cache"], |
| 199 ['ETag', 'abcd'] |
| 200 ] |
| 201 }, |
| 202 { |
| 203 expected_type: "etag_validated", |
| 204 } |
| 205 ] |
| 206 }, |
| 207 { |
| 208 name: 'HTTP cache stores a response with Cache-Control: no-cache, but re
validates upon use, even with max-age and Expires.', |
| 209 requests: [ |
| 210 { |
| 211 response_headers: [ |
| 212 ["Cache-Control", "max-age=10000, no-cache"], |
| 213 ['Expires', http_date(10000)], |
| 214 ['ETag', 'abcd'] |
| 215 ] |
| 216 }, |
| 217 { |
| 218 expected_type: "etag_validated", |
| 219 } |
| 220 ] |
| 221 }, |
| 222 ]; |
| 223 run_tests(tests); |
| 224 </script> |
| 225 </body> |
| 226 </html> |
OLD | NEW |