I am using struts.serve.static=true
and struts.serve.static.browserCache=false
, but the back button is working even after logout. When i click on t
The above constants will be used by S2 to tell browser if they need to cache static content.
struts.serve.static=true
Above property is used by FilterDispatcher
also struts.serve.static.browserCache=true
is used by FilterDispatcher
and will work only if struts.serve.static=true
.
Regarding browser back button we can not disable browser back button as its a part of Browser API and when you are hitting the back button browser is serving the content from its cache without hitting the server.
You can ask the browser not to cache the content by using cache control header but its upon the browser to respect them or not. use following code in your JSP
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
Alternatively you can create an Interceptor and configure it with your desired action so that the headers can be set. Please go through the following thread for more details as how to control the cache in S2
Creating a custom interceptor to add the header to every response
is an easier way than adding response.setHeader
to every jsp (If you are using Struts2).
Please check this link for a beautiful example which works fine.