Res.redirect why can’t you jump and return to Status Code:304 Not Modified?

  node.js, question

Res.redirect why can’t you jump and return to Status Code:304 Not Modified?
clipboard.png

var express=require('express');
var router=express.Router();

/*
 * 1.news---不需要登錄就可以訪問
 * 2.alarm  monitor---需要登錄才能訪問
 * 3.验证用户名密码正确----跳转到alarm
 * 4.验证用户名密码正确---跳转到monitor
 * 5./logout---退出登录--->/dologin页面
 */
router.get('/',function(req,res,next){
    res.render('login',{
        title:"登录"
    });
});

router.post('/dologin',function(req,res,next){
    var user={
        account:"user",
        password:"pass"
    }
    if(req.body.account=='user'&&req.body.password=='pass'){
        res.redirect('/alarm2');
    }else{
        res.redirect('/');
    }
});

router.get('/logout',function(req,res){
    res.redirect('/');
});

//报警页面
router.get('/alarm2',function(req,res,next){
    res.render('boiler_alarm',{
        title:'报警模块'
    });
});

module.exports=router;

I guess it’s becauseexpressWhy is caching enabled by default in the production environment?

Image

You can try this change at the beginning.

# Disable view caching
 app.disable('view cache');

Or in yourdologinSeveral header can also be added to the route.

res.setHeader('Cache-Control', 'no-cache');   res.redirect('alarm2');

Both moves, try to see, should be OK