feat: 100 times cache time for wrong path

This commit is contained in:
DIYgod
2019-09-20 15:24:49 +08:00
parent 57431346bd
commit f7d9688a62
2 changed files with 6 additions and 0 deletions

View File

@@ -2,11 +2,15 @@ const he = require('he');
const mercury_parser = require('@postlight/mercury-parser');
const cheerio = require('cheerio');
const got = require('@/utils/got');
const config = require('@/config').value;
module.exports = async (ctx, next) => {
await next();
if (!ctx.state.data && !ctx._matchedRoute) {
ctx.set({
'Cache-Control': `public, max-age=${config.cache.routeExpire * 100}`,
});
throw Error('wrong path');
}