Authored by 徐炜

错误时不缓存

... ... @@ -5,8 +5,20 @@
const headerModel = require('../models/header');
const logger = global.yoho.logger;
const forceNoCache = (res) => {
if (res) {
res.set({
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: (new Date(1900, 0, 1, 0, 0, 0, 0)).toUTCString()
});
}
};
exports.notFound = () => {
return (req, res, next) => {
forceNoCache(res);
if (req.xhr) {
return res.status(404).json({
code: 404,
... ... @@ -32,6 +44,8 @@ exports.notFound = () => {
*/
exports.serverError = () => {
return (err, req, res, next) => {
forceNoCache(res);
logger.error(`error at path: ${req.url}`);
logger.error(err);
if (!res.headersSent) {
... ...