Authored by 徐炜

错误页面不缓存

... ... @@ -5,15 +5,22 @@
const headerModel = require('../models/header');
const logger = global.yoho.logger;
exports.notFound = () => {
return (req, res) => {
res.status(404);
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) => {
forceNoCache(res);
res.status(404);
if (req.xhr) {
return res.json({
... ... @@ -40,11 +47,7 @@ exports.notFound = () => {
*/
exports.serverError = () => {
return (err, req, res, next) => {
res.set({
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: (new Date(1900, 0, 1, 0, 0, 0, 0)).toUTCString()
});
forceNoCache(res);
logger.error(`error at path: ${req.url}`);
logger.error(err);
... ...