OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <title>HTTP Cache - Cache-Control Request Directives</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 { |
| 18 name: "HTTP cache doesn't use aged but fresh response when request conta
ins Cache-Control: max-age=0.", |
| 19 requests: [ |
| 20 { |
| 21 template: "fresh", |
| 22 pause_after: true |
| 23 }, |
| 24 { |
| 25 request_headers: [ |
| 26 ["Cache-Control", "max-age=0"] |
| 27 ], |
| 28 expected_type: "not_cached", |
| 29 } |
| 30 ] |
| 31 }, |
| 32 { |
| 33 name: "HTTP cache doesn't use aged but fresh response when request conta
ins Cache-Control: max-age=1.", |
| 34 requests: [ |
| 35 { |
| 36 template: "fresh", |
| 37 pause_after: true |
| 38 }, |
| 39 { |
| 40 request_headers: [ |
| 41 ["Cache-Control", "max-age=1"] |
| 42 ], |
| 43 expected_type: "not_cached", |
| 44 } |
| 45 ] |
| 46 }, |
| 47 { |
| 48 name: "HTTP cache doesn't use fresh response with Age header when reques
t contains Cache-Control: max-age that is greater than remaining freshness.", |
| 49 requests: [ |
| 50 { |
| 51 response_headers: [ |
| 52 ["Cache-Control", "max-age=3600"], |
| 53 ["Age", "1800"] |
| 54 ] |
| 55 }, |
| 56 { |
| 57 request_headers: [ |
| 58 ["Cache-Control", "max-age=600"] |
| 59 ], |
| 60 expected_type: "not_cached", |
| 61 } |
| 62 ] |
| 63 }, |
| 64 { |
| 65 name: "HTTP cache does use aged stale response when request contains Cac
he-Control: max-stale that permits its use.", |
| 66 requests: [ |
| 67 { |
| 68 response_headers: [ |
| 69 ["Cache-Control", "max-age=1"] |
| 70 ], |
| 71 pause_after: true |
| 72 }, |
| 73 { |
| 74 request_headers: [ |
| 75 ["Cache-Control", "max-stale=1000"] |
| 76 ], |
| 77 expected_type: "cached", |
| 78 } |
| 79 ] |
| 80 }, |
| 81 { |
| 82 name: "HTTP cache does reuse stale response with Age header when request
contains Cache-Control: max-stale that permits its use.", |
| 83 requests: [ |
| 84 { |
| 85 response_headers: [ |
| 86 ["Cache-Control", "max-age=1500"], |
| 87 ["Age", "2000"] |
| 88 ] |
| 89 }, |
| 90 { |
| 91 request_headers: [ |
| 92 ["Cache-Control", "max-stale=1000"] |
| 93 ], |
| 94 expected_type: "cached", |
| 95 } |
| 96 ] |
| 97 }, |
| 98 { |
| 99 name: "HTTP cache doesn't reuse fresh response when request contains Cac
he-Control: min-fresh that wants it fresher.", |
| 100 requests: [ |
| 101 { |
| 102 response_headers: [ |
| 103 ["Cache-Control", "max-age=1500"] |
| 104 ] |
| 105 }, |
| 106 { |
| 107 request_headers: [ |
| 108 ["Cache-Control", "min-fresh=2000"] |
| 109 ], |
| 110 expected_type: "not_cached", |
| 111 } |
| 112 ] |
| 113 }, |
| 114 { |
| 115 name: "HTTP cache doesn't reuse fresh response with Age header when requ
est contains Cache-Control: min-fresh that wants it fresher.", |
| 116 requests: [ |
| 117 { |
| 118 response_headers: [ |
| 119 ["Cache-Control", "max-age=1500"], |
| 120 ["Age", "1000"] |
| 121 ] |
| 122 }, |
| 123 { |
| 124 request_headers: [ |
| 125 ["Cache-Control", "min-fresh=1000"] |
| 126 ], |
| 127 expected_type: "not_cached", |
| 128 } |
| 129 ] |
| 130 }, |
| 131 { |
| 132 name: "HTTP cache doesn't reuse fresh response when request contains Cac
he-Control: no-cache.", |
| 133 requests: [ |
| 134 { |
| 135 response_headers: [ |
| 136 ["Cache-Control", "max-age=3600"], |
| 137 ] |
| 138 }, |
| 139 { |
| 140 request_headers: [ |
| 141 ["Cache-Control", "no-cache"] |
| 142 ], |
| 143 expected_type: "not_cached", |
| 144 } |
| 145 ] |
| 146 }, |
| 147 { |
| 148 name: "HTTP cache validates fresh response with Last-Modified when reque
st contains Cache-Control: no-cache.", |
| 149 requests: [ |
| 150 { |
| 151 response_headers: [ |
| 152 ["Cache-Control", "max-age=3600"], |
| 153 ["Last-Modified", http_date(-10000)] |
| 154 ] |
| 155 }, |
| 156 { |
| 157 request_headers: [ |
| 158 ["Cache-Control", "no-cache"] |
| 159 ], |
| 160 expected_type: "lm_validate", |
| 161 } |
| 162 ] |
| 163 }, |
| 164 { |
| 165 name: "HTTP cache validates fresh response with ETag when request contai
ns Cache-Control: no-cache.", |
| 166 requests: [ |
| 167 { |
| 168 response_headers: [ |
| 169 ["Cache-Control", "max-age=3600"], |
| 170 ["ETag", http_content("abc")] |
| 171 ] |
| 172 }, |
| 173 { |
| 174 request_headers: [ |
| 175 ["Cache-Control", "no-cache"] |
| 176 ], |
| 177 expected_type: "etag_validate", |
| 178 } |
| 179 ] |
| 180 }, |
| 181 { |
| 182 name: "HTTP cache doesn't reuse fresh response when request contains Cac
he-Control: no-store.", |
| 183 requests: [ |
| 184 { |
| 185 response_headers: [ |
| 186 ["Cache-Control", "max-age=3600"], |
| 187 ] |
| 188 }, |
| 189 { |
| 190 request_headers: [ |
| 191 ["Cache-Control", "no-store"] |
| 192 ], |
| 193 expected_type: "not_cached", |
| 194 } |
| 195 ] |
| 196 }, |
| 197 { |
| 198 name: 'HTTP cache generates 504 status code when nothing is in cache and
request contains Cache-Control: only-if-cached.', |
| 199 requests: [ |
| 200 { |
| 201 request_headers: [ |
| 202 ["Cache-Control", "only-if-cached"] |
| 203 ], |
| 204 expected_status: 504 |
| 205 } |
| 206 ] |
| 207 } |
| 208 ]; |
| 209 run_tests(tests); |
| 210 </script> |
| 211 </body> |
| 212 </html> |
OLD | NEW |