koa-classic-server 2.6.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +101 -0
- package/README.md +564 -591
- package/__tests__/benchmark-results-v3.0.0.txt +372 -0
- package/__tests__/benchmark.js +1 -1
- package/__tests__/caching-headers.test.js +30 -30
- package/__tests__/compression-fixtures/data.json +1 -0
- package/__tests__/compression-fixtures/large.txt +1 -0
- package/__tests__/compression-fixtures/small.txt +1 -0
- package/__tests__/compression.test.js +284 -0
- package/__tests__/customTest/serversToLoad.util.js +5 -5
- package/__tests__/demo-regex-index.js +4 -4
- package/__tests__/deprecation-warnings.test.js +71 -183
- package/__tests__/directory-sorting-links.test.js +1 -1
- package/__tests__/dt-unknown.test.js +39 -28
- package/__tests__/ejs.test.js +1 -1
- package/__tests__/hidden-fixtures/.dot-dir/inside.txt +1 -0
- package/__tests__/hidden-fixtures/.env +2 -0
- package/__tests__/hidden-fixtures/.well-known/acme-challenge.txt +1 -0
- package/__tests__/hidden-fixtures/config/secrets/password.txt +1 -0
- package/__tests__/hidden-fixtures/data.key +1 -0
- package/__tests__/hidden-fixtures/file.secret +1 -0
- package/__tests__/hidden-fixtures/index.html +1 -0
- package/__tests__/hidden-fixtures/normal.txt +1 -0
- package/__tests__/hidden-fixtures/subdir/.env +1 -0
- package/__tests__/hidden-fixtures/subdir/regular.txt +1 -0
- package/__tests__/hidden-option.test.js +407 -0
- package/__tests__/hideExtension.test.js +70 -13
- package/__tests__/index-option.test.js +18 -16
- package/__tests__/index.test.js +14 -10
- package/__tests__/listing.test.js +437 -0
- package/__tests__/logger.test.js +232 -0
- package/__tests__/range-fixtures/sample.txt +1 -0
- package/__tests__/range.test.js +223 -0
- package/__tests__/security-headers.test.js +165 -0
- package/__tests__/security.test.js +148 -162
- package/__tests__/server-cache-fixtures/large.txt +1 -0
- package/__tests__/server-cache-fixtures/small.txt +1 -0
- package/__tests__/server-cache.test.js +594 -0
- package/__tests__/symlink.test.js +18 -15
- package/__tests__/template-timeout.test.js +321 -0
- package/docs/ACTION_PLAN.md +293 -0
- package/docs/CHANGELOG.md +289 -0
- package/docs/CODE_REVIEW.md +2 -0
- package/docs/DOCUMENTATION.md +259 -32
- package/docs/EXAMPLES_INDEX_OPTION.md +3 -3
- package/docs/FLOW_DIAGRAM.md +15 -13
- package/docs/INDEX_OPTION_PRIORITY.md +2 -2
- package/docs/OPTIMIZATION_HTTP_CACHING.md +2 -0
- package/docs/OPTIMIZATION_ROADMAP_for_V3.md +864 -0
- package/docs/PERFORMANCE_COMPARISON.md +7 -7
- package/docs/security_improvement_for_V3.md +421 -0
- package/docs/template-engine/TEMPLATE_ENGINE_GUIDE.md +5 -5
- package/docs/template-engine/esempi-incrementali.js +1 -1
- package/eslint.config.mjs +17 -0
- package/index.cjs +1507 -429
- package/index.mjs +1 -5
- package/package.json +9 -1
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
|
|
2
|
+
> koa-classic-server@3.0.0-alpha.0 test:performance
|
|
3
|
+
> jest __tests__/performance.test.js --runInBand
|
|
4
|
+
|
|
5
|
+
console.warn
|
|
6
|
+
[33m[koa-classic-server] WARNING: hidden.dotFiles.default and/or hidden.dotDirs.default are not explicitly set.
|
|
7
|
+
Since v3.0.0 the defaults are: dotFiles → "hidden", dotDirs → "visible".
|
|
8
|
+
To suppress this warning, add to your configuration:
|
|
9
|
+
hidden: { dotFiles: { default: 'hidden' }, dotDirs: { default: 'visible' } }
|
|
10
|
+
(adjust values to match your desired behaviour)[0m
|
|
11
|
+
|
|
12
|
+
735 | if (dotFilesImplicit || dotDirsImplicit) {
|
|
13
|
+
736 | _hiddenDefaultWarnEmitted = true;
|
|
14
|
+
> 737 | _logger.warn(...warnPayload(_logger,
|
|
15
|
+
| ^
|
|
16
|
+
738 | '[koa-classic-server] WARNING: hidden.dotFiles.default and/or hidden.dotDirs.default are not explicitly set.\n' +
|
|
17
|
+
739 | ' Since v3.0.0 the defaults are: dotFiles → "hidden", dotDirs → "visible".\n' +
|
|
18
|
+
740 | ' To suppress this warning, add to your configuration:\n' +
|
|
19
|
+
|
|
20
|
+
at koaClassicServer (index.cjs:737:21)
|
|
21
|
+
at Object.koaClassicServer (__tests__/performance.test.js:139:17)
|
|
22
|
+
|
|
23
|
+
console.log
|
|
24
|
+
|
|
25
|
+
📊 Small File (1KB) Benchmark:
|
|
26
|
+
|
|
27
|
+
at Object.log (__tests__/performance.test.js:159:21)
|
|
28
|
+
|
|
29
|
+
console.log
|
|
30
|
+
Average: 2.09ms
|
|
31
|
+
|
|
32
|
+
at Object.log (__tests__/performance.test.js:160:21)
|
|
33
|
+
|
|
34
|
+
console.log
|
|
35
|
+
Median: 1.66ms
|
|
36
|
+
|
|
37
|
+
at Object.log (__tests__/performance.test.js:161:21)
|
|
38
|
+
|
|
39
|
+
console.log
|
|
40
|
+
Min: 1.40ms
|
|
41
|
+
|
|
42
|
+
at Object.log (__tests__/performance.test.js:162:21)
|
|
43
|
+
|
|
44
|
+
console.log
|
|
45
|
+
Max: 22.92ms
|
|
46
|
+
|
|
47
|
+
at Object.log (__tests__/performance.test.js:163:21)
|
|
48
|
+
|
|
49
|
+
console.log
|
|
50
|
+
|
|
51
|
+
📊 Medium File (100KB) Benchmark:
|
|
52
|
+
|
|
53
|
+
at Object.log (__tests__/performance.test.js:178:21)
|
|
54
|
+
|
|
55
|
+
console.log
|
|
56
|
+
Average: 2.06ms
|
|
57
|
+
|
|
58
|
+
at Object.log (__tests__/performance.test.js:179:21)
|
|
59
|
+
|
|
60
|
+
console.log
|
|
61
|
+
Median: 1.93ms
|
|
62
|
+
|
|
63
|
+
at Object.log (__tests__/performance.test.js:180:21)
|
|
64
|
+
|
|
65
|
+
console.log
|
|
66
|
+
Min: 1.65ms
|
|
67
|
+
|
|
68
|
+
at Object.log (__tests__/performance.test.js:181:21)
|
|
69
|
+
|
|
70
|
+
console.log
|
|
71
|
+
Max: 4.47ms
|
|
72
|
+
|
|
73
|
+
at Object.log (__tests__/performance.test.js:182:21)
|
|
74
|
+
|
|
75
|
+
console.log
|
|
76
|
+
|
|
77
|
+
📊 Large File (1MB) Benchmark:
|
|
78
|
+
|
|
79
|
+
at Object.log (__tests__/performance.test.js:197:21)
|
|
80
|
+
|
|
81
|
+
console.log
|
|
82
|
+
Average: 7.19ms
|
|
83
|
+
|
|
84
|
+
at Object.log (__tests__/performance.test.js:198:21)
|
|
85
|
+
|
|
86
|
+
console.log
|
|
87
|
+
Median: 5.82ms
|
|
88
|
+
|
|
89
|
+
at Object.log (__tests__/performance.test.js:199:21)
|
|
90
|
+
|
|
91
|
+
console.log
|
|
92
|
+
Min: 4.53ms
|
|
93
|
+
|
|
94
|
+
at Object.log (__tests__/performance.test.js:200:21)
|
|
95
|
+
|
|
96
|
+
console.log
|
|
97
|
+
Max: 21.60ms
|
|
98
|
+
|
|
99
|
+
at Object.log (__tests__/performance.test.js:201:21)
|
|
100
|
+
|
|
101
|
+
console.log
|
|
102
|
+
|
|
103
|
+
📊 Small Directory (100 files) Benchmark:
|
|
104
|
+
|
|
105
|
+
at Object.log (__tests__/performance.test.js:219:21)
|
|
106
|
+
|
|
107
|
+
console.log
|
|
108
|
+
Average: 5.22ms
|
|
109
|
+
|
|
110
|
+
at Object.log (__tests__/performance.test.js:220:21)
|
|
111
|
+
|
|
112
|
+
console.log
|
|
113
|
+
Median: 4.65ms
|
|
114
|
+
|
|
115
|
+
at Object.log (__tests__/performance.test.js:221:21)
|
|
116
|
+
|
|
117
|
+
console.log
|
|
118
|
+
Min: 4.03ms
|
|
119
|
+
|
|
120
|
+
at Object.log (__tests__/performance.test.js:222:21)
|
|
121
|
+
|
|
122
|
+
console.log
|
|
123
|
+
Max: 17.47ms
|
|
124
|
+
|
|
125
|
+
at Object.log (__tests__/performance.test.js:223:21)
|
|
126
|
+
|
|
127
|
+
console.log
|
|
128
|
+
|
|
129
|
+
📊 Large Directory (1,000 files) Benchmark:
|
|
130
|
+
|
|
131
|
+
at Object.log (__tests__/performance.test.js:237:21)
|
|
132
|
+
|
|
133
|
+
console.log
|
|
134
|
+
Average: 28.83ms
|
|
135
|
+
|
|
136
|
+
at Object.log (__tests__/performance.test.js:238:21)
|
|
137
|
+
|
|
138
|
+
console.log
|
|
139
|
+
Median: 28.80ms
|
|
140
|
+
|
|
141
|
+
at Object.log (__tests__/performance.test.js:239:21)
|
|
142
|
+
|
|
143
|
+
console.log
|
|
144
|
+
Min: 26.80ms
|
|
145
|
+
|
|
146
|
+
at Object.log (__tests__/performance.test.js:240:21)
|
|
147
|
+
|
|
148
|
+
console.log
|
|
149
|
+
Max: 31.02ms
|
|
150
|
+
|
|
151
|
+
at Object.log (__tests__/performance.test.js:241:21)
|
|
152
|
+
|
|
153
|
+
console.log
|
|
154
|
+
⚠️ WARNING: This will be MUCH faster after async optimization
|
|
155
|
+
|
|
156
|
+
at Object.log (__tests__/performance.test.js:244:21)
|
|
157
|
+
|
|
158
|
+
console.log
|
|
159
|
+
|
|
160
|
+
📊 Very Large Directory (10,000 files) Benchmark:
|
|
161
|
+
|
|
162
|
+
at Object.log (__tests__/performance.test.js:258:21)
|
|
163
|
+
|
|
164
|
+
console.log
|
|
165
|
+
Average: 265.99ms
|
|
166
|
+
|
|
167
|
+
at Object.log (__tests__/performance.test.js:259:21)
|
|
168
|
+
|
|
169
|
+
console.log
|
|
170
|
+
Median: 266.27ms
|
|
171
|
+
|
|
172
|
+
at Object.log (__tests__/performance.test.js:260:21)
|
|
173
|
+
|
|
174
|
+
console.log
|
|
175
|
+
Min: 261.83ms
|
|
176
|
+
|
|
177
|
+
at Object.log (__tests__/performance.test.js:261:21)
|
|
178
|
+
|
|
179
|
+
console.log
|
|
180
|
+
Max: 271.55ms
|
|
181
|
+
|
|
182
|
+
at Object.log (__tests__/performance.test.js:262:21)
|
|
183
|
+
|
|
184
|
+
console.log
|
|
185
|
+
⚠️ WARNING: Event loop BLOCKED during this operation!
|
|
186
|
+
|
|
187
|
+
at Object.log (__tests__/performance.test.js:263:21)
|
|
188
|
+
|
|
189
|
+
console.log
|
|
190
|
+
⚠️ Expected to drop to ~79.80ms after optimization
|
|
191
|
+
|
|
192
|
+
at Object.log (__tests__/performance.test.js:264:21)
|
|
193
|
+
|
|
194
|
+
console.log
|
|
195
|
+
|
|
196
|
+
📊 10 Concurrent Small Files:
|
|
197
|
+
|
|
198
|
+
at Object.log (__tests__/performance.test.js:281:21)
|
|
199
|
+
|
|
200
|
+
console.log
|
|
201
|
+
Total time: 13.28ms
|
|
202
|
+
|
|
203
|
+
at Object.log (__tests__/performance.test.js:282:21)
|
|
204
|
+
|
|
205
|
+
console.log
|
|
206
|
+
Avg per request: 1.33ms
|
|
207
|
+
|
|
208
|
+
at Object.log (__tests__/performance.test.js:283:21)
|
|
209
|
+
|
|
210
|
+
console.log
|
|
211
|
+
|
|
212
|
+
📊 5 Concurrent Directory Listings (100 files):
|
|
213
|
+
|
|
214
|
+
at Object.log (__tests__/performance.test.js:300:21)
|
|
215
|
+
|
|
216
|
+
console.log
|
|
217
|
+
Total time: 18.73ms
|
|
218
|
+
|
|
219
|
+
at Object.log (__tests__/performance.test.js:301:21)
|
|
220
|
+
|
|
221
|
+
console.log
|
|
222
|
+
Avg per request: 3.75ms
|
|
223
|
+
|
|
224
|
+
at Object.log (__tests__/performance.test.js:302:21)
|
|
225
|
+
|
|
226
|
+
console.log
|
|
227
|
+
⚠️ With current sync code, these run SEQUENTIALLY
|
|
228
|
+
|
|
229
|
+
at Object.log (__tests__/performance.test.js:303:21)
|
|
230
|
+
|
|
231
|
+
console.log
|
|
232
|
+
⚠️ After async optimization, will run in PARALLEL
|
|
233
|
+
|
|
234
|
+
at Object.log (__tests__/performance.test.js:304:21)
|
|
235
|
+
|
|
236
|
+
console.log
|
|
237
|
+
|
|
238
|
+
📊 404 Not Found Benchmark:
|
|
239
|
+
|
|
240
|
+
at Object.log (__tests__/performance.test.js:321:21)
|
|
241
|
+
|
|
242
|
+
console.log
|
|
243
|
+
Average: 1.26ms
|
|
244
|
+
|
|
245
|
+
at Object.log (__tests__/performance.test.js:322:21)
|
|
246
|
+
|
|
247
|
+
console.log
|
|
248
|
+
Median: 1.11ms
|
|
249
|
+
|
|
250
|
+
at Object.log (__tests__/performance.test.js:323:21)
|
|
251
|
+
|
|
252
|
+
console.log
|
|
253
|
+
Min: 0.92ms
|
|
254
|
+
|
|
255
|
+
at Object.log (__tests__/performance.test.js:324:21)
|
|
256
|
+
|
|
257
|
+
console.log
|
|
258
|
+
Max: 3.88ms
|
|
259
|
+
|
|
260
|
+
at Object.log (__tests__/performance.test.js:325:21)
|
|
261
|
+
|
|
262
|
+
console.log
|
|
263
|
+
|
|
264
|
+
📊 Memory Usage (10,000 files directory):
|
|
265
|
+
|
|
266
|
+
at Object.log (__tests__/performance.test.js:347:21)
|
|
267
|
+
|
|
268
|
+
console.log
|
|
269
|
+
Heap used increase: 6.97 MB
|
|
270
|
+
|
|
271
|
+
at Object.log (__tests__/performance.test.js:348:21)
|
|
272
|
+
|
|
273
|
+
console.log
|
|
274
|
+
External increase: 0.25 MB
|
|
275
|
+
|
|
276
|
+
at Object.log (__tests__/performance.test.js:349:21)
|
|
277
|
+
|
|
278
|
+
console.log
|
|
279
|
+
Response size: 0.02 MB
|
|
280
|
+
|
|
281
|
+
at Object.log (__tests__/performance.test.js:350:21)
|
|
282
|
+
|
|
283
|
+
console.log
|
|
284
|
+
⚠️ Expected to reduce by ~30-40% after optimization
|
|
285
|
+
|
|
286
|
+
at Object.log (__tests__/performance.test.js:351:21)
|
|
287
|
+
|
|
288
|
+
console.log
|
|
289
|
+
|
|
290
|
+
======================================================================
|
|
291
|
+
|
|
292
|
+
at Object.log (__tests__/performance.test.js:358:13)
|
|
293
|
+
|
|
294
|
+
console.log
|
|
295
|
+
📋 BASELINE BENCHMARK SUMMARY
|
|
296
|
+
|
|
297
|
+
at Object.log (__tests__/performance.test.js:359:13)
|
|
298
|
+
|
|
299
|
+
console.log
|
|
300
|
+
======================================================================
|
|
301
|
+
|
|
302
|
+
at Object.log (__tests__/performance.test.js:360:13)
|
|
303
|
+
|
|
304
|
+
console.log
|
|
305
|
+
|
|
306
|
+
These results represent the CURRENT performance (v1.2.0)
|
|
307
|
+
|
|
308
|
+
at Object.log (__tests__/performance.test.js:361:13)
|
|
309
|
+
|
|
310
|
+
console.log
|
|
311
|
+
After implementing optimizations, run this test again to see improvements.
|
|
312
|
+
|
|
313
|
+
at Object.log (__tests__/performance.test.js:362:13)
|
|
314
|
+
|
|
315
|
+
console.log
|
|
316
|
+
Expected improvements after optimization:
|
|
317
|
+
|
|
318
|
+
at Object.log (__tests__/performance.test.js:363:13)
|
|
319
|
+
|
|
320
|
+
console.log
|
|
321
|
+
✓ Small files: 10-20% faster (async operations)
|
|
322
|
+
|
|
323
|
+
at Object.log (__tests__/performance.test.js:364:13)
|
|
324
|
+
|
|
325
|
+
console.log
|
|
326
|
+
✓ Large directories: 50-70% faster (async + array join)
|
|
327
|
+
|
|
328
|
+
at Object.log (__tests__/performance.test.js:365:13)
|
|
329
|
+
|
|
330
|
+
console.log
|
|
331
|
+
✓ Concurrent requests: 5-10x faster (non-blocking event loop)
|
|
332
|
+
|
|
333
|
+
at Object.log (__tests__/performance.test.js:366:13)
|
|
334
|
+
|
|
335
|
+
console.log
|
|
336
|
+
✓ Memory usage: 30-40% reduction (array join vs concatenation)
|
|
337
|
+
|
|
338
|
+
at Object.log (__tests__/performance.test.js:367:13)
|
|
339
|
+
|
|
340
|
+
console.log
|
|
341
|
+
✓ With HTTP caching: 80-95% faster (304 responses)
|
|
342
|
+
|
|
343
|
+
at Object.log (__tests__/performance.test.js:368:13)
|
|
344
|
+
|
|
345
|
+
console.log
|
|
346
|
+
======================================================================
|
|
347
|
+
|
|
348
|
+
at Object.log (__tests__/performance.test.js:369:13)
|
|
349
|
+
|
|
350
|
+
PASS __tests__/performance.test.js
|
|
351
|
+
Performance Benchmarks - BASELINE (v1.2.0)
|
|
352
|
+
File Serving Performance
|
|
353
|
+
✓ Benchmark: Small file (1KB) - 100 iterations (215 ms)
|
|
354
|
+
✓ Benchmark: Medium file (100KB) - 50 iterations (107 ms)
|
|
355
|
+
✓ Benchmark: Large file (1MB) - 20 iterations (146 ms)
|
|
356
|
+
Directory Listing Performance
|
|
357
|
+
✓ Benchmark: Small directory (100 files) - 50 iterations (264 ms)
|
|
358
|
+
✓ Benchmark: Large directory (1,000 files) - 20 iterations (579 ms)
|
|
359
|
+
✓ Benchmark: Very large directory (10,000 files) - 5 iterations (1333 ms)
|
|
360
|
+
Concurrent Request Performance
|
|
361
|
+
✓ Benchmark: 10 concurrent small file requests (15 ms)
|
|
362
|
+
✓ Benchmark: 5 concurrent directory listings (100 files each) (21 ms)
|
|
363
|
+
404 Not Found Performance
|
|
364
|
+
✓ Benchmark: Non-existent file - 50 iterations (65 ms)
|
|
365
|
+
Memory Usage (Informational)
|
|
366
|
+
✓ Memory usage during large directory listing (269 ms)
|
|
367
|
+
|
|
368
|
+
Test Suites: 1 passed, 1 total
|
|
369
|
+
Tests: 10 passed, 10 total
|
|
370
|
+
Snapshots: 0 total
|
|
371
|
+
Time: 3.365 s, estimated 5 s
|
|
372
|
+
Ran all test suites matching __tests__/performance.test.js.
|
package/__tests__/benchmark.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* HTTP Caching Headers Test
|
|
3
3
|
*
|
|
4
4
|
* Tests to verify correct caching behavior:
|
|
5
|
-
* - When
|
|
6
|
-
* - When
|
|
5
|
+
* - When browserCacheEnabled: true -> proper cache headers
|
|
6
|
+
* - When browserCacheEnabled: false -> anti-cache headers
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const Koa = require('koa');
|
|
@@ -30,7 +30,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
describe('When caching is DISABLED (
|
|
33
|
+
describe('When caching is DISABLED (browserCacheEnabled: false)', () => {
|
|
34
34
|
let app;
|
|
35
35
|
let server;
|
|
36
36
|
let request;
|
|
@@ -38,7 +38,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
38
38
|
beforeAll(() => {
|
|
39
39
|
app = new Koa();
|
|
40
40
|
app.use(koaClassicServer(TEST_DIR, {
|
|
41
|
-
|
|
41
|
+
browserCacheEnabled: false
|
|
42
42
|
}));
|
|
43
43
|
server = app.listen();
|
|
44
44
|
request = supertest(server);
|
|
@@ -89,7 +89,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
89
89
|
});
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
describe('When caching is ENABLED (
|
|
92
|
+
describe('When caching is ENABLED (browserCacheEnabled: true)', () => {
|
|
93
93
|
let app;
|
|
94
94
|
let server;
|
|
95
95
|
let request;
|
|
@@ -97,8 +97,8 @@ describe('HTTP Caching Headers', () => {
|
|
|
97
97
|
beforeAll(() => {
|
|
98
98
|
app = new Koa();
|
|
99
99
|
app.use(koaClassicServer(TEST_DIR, {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
browserCacheEnabled: true,
|
|
101
|
+
browserCacheMaxAge: 3600
|
|
102
102
|
}));
|
|
103
103
|
server = app.listen();
|
|
104
104
|
request = supertest(server);
|
|
@@ -173,7 +173,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
173
173
|
|
|
174
174
|
beforeAll(() => {
|
|
175
175
|
app = new Koa();
|
|
176
|
-
// No options provided - should default to
|
|
176
|
+
// No options provided - should default to browserCacheEnabled: false
|
|
177
177
|
app.use(koaClassicServer(TEST_DIR));
|
|
178
178
|
server = app.listen();
|
|
179
179
|
request = supertest(server);
|
|
@@ -193,12 +193,12 @@ describe('HTTP Caching Headers', () => {
|
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
195
|
|
|
196
|
-
describe('Custom
|
|
197
|
-
test('Should respect custom
|
|
196
|
+
describe('Custom browserCacheMaxAge values', () => {
|
|
197
|
+
test('Should respect custom browserCacheMaxAge: 7200', async () => {
|
|
198
198
|
const app = new Koa();
|
|
199
199
|
app.use(koaClassicServer(TEST_DIR, {
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
browserCacheEnabled: true,
|
|
201
|
+
browserCacheMaxAge: 7200
|
|
202
202
|
}));
|
|
203
203
|
const server = app.listen();
|
|
204
204
|
const request = supertest(server);
|
|
@@ -211,11 +211,11 @@ describe('HTTP Caching Headers', () => {
|
|
|
211
211
|
server.close();
|
|
212
212
|
});
|
|
213
213
|
|
|
214
|
-
test('Should respect custom
|
|
214
|
+
test('Should respect custom browserCacheMaxAge: 0 (no browser cache)', async () => {
|
|
215
215
|
const app = new Koa();
|
|
216
216
|
app.use(koaClassicServer(TEST_DIR, {
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
browserCacheEnabled: true,
|
|
218
|
+
browserCacheMaxAge: 0
|
|
219
219
|
}));
|
|
220
220
|
const server = app.listen();
|
|
221
221
|
const request = supertest(server);
|
|
@@ -230,11 +230,11 @@ describe('HTTP Caching Headers', () => {
|
|
|
230
230
|
server.close();
|
|
231
231
|
});
|
|
232
232
|
|
|
233
|
-
test('Should respect custom
|
|
233
|
+
test('Should respect custom browserCacheMaxAge: 86400 (1 day)', async () => {
|
|
234
234
|
const app = new Koa();
|
|
235
235
|
app.use(koaClassicServer(TEST_DIR, {
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
browserCacheEnabled: true,
|
|
237
|
+
browserCacheMaxAge: 86400
|
|
238
238
|
}));
|
|
239
239
|
const server = app.listen();
|
|
240
240
|
const request = supertest(server);
|
|
@@ -255,7 +255,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
255
255
|
|
|
256
256
|
const app = new Koa();
|
|
257
257
|
app.use(koaClassicServer(TEST_DIR, {
|
|
258
|
-
|
|
258
|
+
browserCacheEnabled: true
|
|
259
259
|
}));
|
|
260
260
|
const server = app.listen();
|
|
261
261
|
const request = supertest(server);
|
|
@@ -290,7 +290,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
290
290
|
|
|
291
291
|
const app = new Koa();
|
|
292
292
|
app.use(koaClassicServer(TEST_DIR, {
|
|
293
|
-
|
|
293
|
+
browserCacheEnabled: true
|
|
294
294
|
}));
|
|
295
295
|
const server = app.listen();
|
|
296
296
|
const request = supertest(server);
|
|
@@ -318,7 +318,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
318
318
|
test('304 response should have no body', async () => {
|
|
319
319
|
const app = new Koa();
|
|
320
320
|
app.use(koaClassicServer(TEST_DIR, {
|
|
321
|
-
|
|
321
|
+
browserCacheEnabled: true
|
|
322
322
|
}));
|
|
323
323
|
const server = app.listen();
|
|
324
324
|
const request = supertest(server);
|
|
@@ -348,7 +348,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
348
348
|
test('Should save bandwidth on multiple 304 responses', async () => {
|
|
349
349
|
const app = new Koa();
|
|
350
350
|
app.use(koaClassicServer(TEST_DIR, {
|
|
351
|
-
|
|
351
|
+
browserCacheEnabled: true
|
|
352
352
|
}));
|
|
353
353
|
const server = app.listen();
|
|
354
354
|
const request = supertest(server);
|
|
@@ -394,7 +394,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
394
394
|
test('HTML files should have cache headers', async () => {
|
|
395
395
|
const app = new Koa();
|
|
396
396
|
app.use(koaClassicServer(TEST_DIR, {
|
|
397
|
-
|
|
397
|
+
browserCacheEnabled: true
|
|
398
398
|
}));
|
|
399
399
|
const server = app.listen();
|
|
400
400
|
const request = supertest(server);
|
|
@@ -411,7 +411,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
411
411
|
test('JSON files should have cache headers', async () => {
|
|
412
412
|
const app = new Koa();
|
|
413
413
|
app.use(koaClassicServer(TEST_DIR, {
|
|
414
|
-
|
|
414
|
+
browserCacheEnabled: true
|
|
415
415
|
}));
|
|
416
416
|
const server = app.listen();
|
|
417
417
|
const request = supertest(server);
|
|
@@ -427,7 +427,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
427
427
|
test('CSS files should have cache headers', async () => {
|
|
428
428
|
const app = new Koa();
|
|
429
429
|
app.use(koaClassicServer(TEST_DIR, {
|
|
430
|
-
|
|
430
|
+
browserCacheEnabled: true
|
|
431
431
|
}));
|
|
432
432
|
const server = app.listen();
|
|
433
433
|
const request = supertest(server);
|
|
@@ -443,7 +443,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
443
443
|
test('JavaScript files should have cache headers', async () => {
|
|
444
444
|
const app = new Koa();
|
|
445
445
|
app.use(koaClassicServer(TEST_DIR, {
|
|
446
|
-
|
|
446
|
+
browserCacheEnabled: true
|
|
447
447
|
}));
|
|
448
448
|
const server = app.listen();
|
|
449
449
|
const request = supertest(server);
|
|
@@ -466,8 +466,8 @@ describe('HTTP Caching Headers', () => {
|
|
|
466
466
|
|
|
467
467
|
const app = new Koa();
|
|
468
468
|
app.use(koaClassicServer(TEST_DIR, {
|
|
469
|
-
|
|
470
|
-
|
|
469
|
+
browserCacheEnabled: true,
|
|
470
|
+
browserCacheMaxAge: 3600,
|
|
471
471
|
template: {
|
|
472
472
|
ext: ['ejs'],
|
|
473
473
|
render: async (ctx, next, filePath) => {
|
|
@@ -499,7 +499,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
499
499
|
test('Multiple concurrent requests should handle caching correctly', async () => {
|
|
500
500
|
const app = new Koa();
|
|
501
501
|
app.use(koaClassicServer(TEST_DIR, {
|
|
502
|
-
|
|
502
|
+
browserCacheEnabled: true
|
|
503
503
|
}));
|
|
504
504
|
const server = app.listen();
|
|
505
505
|
const request = supertest(server);
|
|
@@ -528,7 +528,7 @@ describe('HTTP Caching Headers', () => {
|
|
|
528
528
|
test('Concurrent 304 responses should work correctly', async () => {
|
|
529
529
|
const app = new Koa();
|
|
530
530
|
app.use(koaClassicServer(TEST_DIR, {
|
|
531
|
-
|
|
531
|
+
browserCacheEnabled: true
|
|
532
532
|
}));
|
|
533
533
|
const server = app.listen();
|
|
534
534
|
const request = supertest(server);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"key":"value"}
|
|
@@ -0,0 +1 @@
|
|
|
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