mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(core/parameter): absurd wrong path cache time (#9796)
Signed-off-by: Rongrong <i@rong.moe>
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
@@ -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/);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user