diff --git a/lib/middleware/parameter.js b/lib/middleware/parameter.js index 65e28ecbc1..0c98d0a559 100644 --- a/lib/middleware/parameter.js +++ b/lib/middleware/parameter.js @@ -10,9 +10,17 @@ module.exports = async (ctx, next) => { await next(); if (!ctx.state.data && !ctx._matchedRoute) { - ctx.set({ - 'Cache-Control': `public, max-age=${config.cache.routeExpire * 100}`, - }); + // Given that the official demo has a cache TTL of 2h, a "wrong path" page will be cached by CloudFlare for + // 200h (8.33d). + // What makes it worse is that the documentation contains status badges to detect the availability of routes, + // but the documentation is updated more timely than the official demo, so the every example path of every + // new route will probably have a "wrong path" page cached for at least 200h soon after accepted. That is to + // say, the example paths of a new route will probably be unavailable on the public demo in the first 200h + // after accepted. + // As a conclusion, the next 3 lines has been commented out. (exactly the same behavior as any internal error) + // ctx.set({ + // 'Cache-Control': `public, max-age=${config.cache.routeExpire * 100}`, + // }); throw Error('wrong path'); } diff --git a/test/middleware/parameter.js b/test/middleware/parameter.js index f3fe9dcfaa..24234fa1cc 100644 --- a/test/middleware/parameter.js +++ b/test/middleware/parameter.js @@ -246,7 +246,7 @@ describe('wrong_path', () => { it(`wrong_path`, async () => { const response = await request.get('/wrong'); expect(response.status).toBe(404); - expect(response.headers['cache-control']).toBe(`public, max-age=${config.cache.routeExpire * 100}`); + expect(response.headers['cache-control']).toBe(`public, max-age=${config.cache.routeExpire}`); expect(response.text).toMatch(/Error: wrong path/); }); });