Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6067865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:39:16+00:00 2026-05-23T09:39:16+00:00

I have a restricted area ‘/dashboard’ in my Express application. I use a very

  • 0

I have a restricted area ‘/dashboard’ in my Express application. I use a very small function to limit the access:

app.get('/dashboard', loadUser, function(req, res){
  res.render('dashboard', {
    username: req.session.username
  });
});

function loadUser(req, res, next){
  if (req.session.auth) {
    next();
  } else {
    res.redirect('/login');
  }
};

The problem is that when I logout a user by calling…

app.get('/logout', function(req, res){
  if (req.session) {
    req.session.auth = null;
    res.clearCookie('auth');
    req.session.destroy(function() {});
  }
  res.redirect('/login');
});

… the session is killed but when I hit Back Button in my browser I got the restricted page from browser’s cache. This means no GET on ‘/dashboard’ and no user login validation.

I tried using no-cache in meta (Jade Template) but it still doesn’t work.

meta(http-equiv='Cache-Control', content='no-store, no-cache, must-revalidate')
meta(http-equiv='Pragma', content='no-cache')
meta(http-equiv='Expires', content='-1')

Anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:39:17+00:00Added an answer on May 23, 2026 at 9:39 am

    Josh’s answer sadly didn’t work for me.
    But after some searching I found this
    question: What's the best way to deal with cache and the browser back button?

    and adopted the answer there to this node.js/express problem.
    You just have to change the following line

    res.header('Cache-Control', 'no-cache');
    

    to

    res.header('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
    

    Now, everytime I use the browser back button, the page is reloaded and not cached.

    * update for express v4.x *

    // caching disabled for every route
    server.use(function(req, res, next) {
      res.set('Cache-Control', 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0');
      next();
    });
    
    // otherwise put the res.set() call into the route-handler you want
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a client apllication that run in very restricted area - it has
I have a web app using forms authentication and I have restricted a folder
I have a function which restricts access to some of the places on my
I have a text area which i put a 250 character limit on for
I have a social networking site in which we have a restricted community. When
I have some age-restricted content needed to confirm 18 years old stuff. so I
In AD we have these two OUs: OU=Accounts - Standard User OU=Accounts - Restricted
but cant find any information. Restricted on time. I have a Datagridview, 6 fields.
We have a server application that we want to restrict non-users from triggerring it
I have a website admin area I want to protect with a password.. so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.