-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathconditional-lm.mjs
119 lines (118 loc) · 3.46 KB
/
conditional-lm.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import * as templates from './lib/templates.mjs'
export default {
name: 'Conditional Requests: If-Modified-Since and Last-Modified',
id: 'conditional-lm',
description: 'These tests check handling of conditional requests using `If-Modified-Since` and `Last-Modified`.',
spec_anchors: ['validation.model'],
tests: [
{
name: 'An optimal HTTP cache responds to `If-Modified-Since` with a `304` when holding a fresh response with a matching `Last-Modified`',
id: 'conditional-lm-fresh',
kind: 'optimal',
depends_on: ['freshness-max-age'],
browser_skip: true,
requests: [
templates.fresh({
response_headers: [
['Last-Modified', -3000]
]
}),
{
request_headers: [
['If-Modified-Since', -3000]
],
magic_ims: true,
expected_type: 'cached',
expected_status: 304
}
]
},
{
name: 'An optimal HTTP cache responds to `If-Modified-Since` with a `304` when holding a fresh response with an earlier `Last-Modified`',
id: 'conditional-lm-fresh-earlier',
kind: 'optimal',
depends_on: ['freshness-max-age'],
browser_skip: true,
requests: [
templates.fresh({
response_headers: [
['Last-Modified', -3000]
]
}),
{
request_headers: [
['If-Modified-Since', -2000]
],
magic_ims: true,
expected_type: 'cached',
expected_status: 304
}
]
},
{
name: 'An optimal HTTP cache responds to `If-Modified-Since` with a `304` when holding a stale response with a matching `Last-Modified`, after validation',
id: 'conditional-lm-stale',
kind: 'optimal',
depends_on: ['freshness-max-age-stale'],
browser_skip: true,
requests: [
templates.becomeStale({
response_headers: [
['Last-Modified', -3000]
]
}),
{
request_headers: [
['If-Modified-Since', -3000]
],
magic_ims: true,
expected_type: 'lm_validated',
expected_status: 304
}
]
},
{
name: 'An optimal HTTP cache responds to `If-Modified-Since` with a `304` when holding a newer fresh response with no `Last-Modified`',
id: 'conditional-lm-fresh-no-lm',
kind: 'optimal',
depends_on: ['freshness-max-age'],
browser_skip: true,
requests: [
templates.fresh({}),
{
request_headers: [
['If-Modified-Since', -3000]
],
magic_ims: true,
expected_type: 'cached',
expected_status: 304,
setup_tests: ['expected_type']
}
]
},
{
name: 'An optimal HTTP cache responds to `If-Modified-Since` with a `304` when holding a newer fresh response when IMS uses an equivalent rfc850 date',
id: 'conditional-lm-fresh-rfc850',
kind: 'optimal',
depends_on: ['freshness-max-age'],
browser_skip: true,
requests: [
templates.fresh({
response_headers: [
['Last-Modified', -3000]
]
}),
{
request_headers: [
['If-Modified-Since', -3000]
],
magic_ims: true,
rfc850date: ['if-modified-since'],
expected_type: 'cached',
expected_status: 304,
setup_tests: ['expected_type']
}
]
}
]
}