java - How to prevent the result of Servlets from being cached? -


how can stop caching of pages in browser using servlets?

i want session should expire if press button of browser when logged in.

to permanently disable cache.

  // set expire far in past.   response.setheader("expires", "sat, 6 may 1995 12:00:00 gmt");    // set standard http/1.1 no-cache headers.   response.setheader("cache-control", "no-store, no-cache, must-revalidate");    // set ie extended http/1.1 no-cache headers (use addheader).   response.addheader("cache-control", "post-check=0, pre-check=0");    // set standard http/1.0 no-cache header.   response.setheader("pragma", "no-cache"); 

clearing client cache not expire session immediately,but clears session cookies in browser. make session expire immediately, need explicitly specify in server side jsp or servlet.

// use session invalidate session.invalidate(); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -