Raghavender Reddy
Raghavender Reddy

Reputation: 180

struts.serve.static=true and struts,serve.static.browserCache=false not working

Browser caching using struts.serve.static=true and struts,serve.static.browserCache=false tags is not working I have a requirement when even the user logout and click on back button it is showing welcome screen to avoid this i configured in Struts.xml

   <constant name="struts.serve.static" value="true" />
   <constant name="struts.serve.static.browserCache" value="false" />

But still it is not happening finally i tried by placing struts.serve.static=true and struts,serve.static.browserCache=false in message resource properties file it is not working could you please help me how to resolve this issue even it is not working

Upvotes: 1

Views: 1513

Answers (1)

Umesh Awasthi
Umesh Awasthi

Reputation: 23587

Above constant will be used by S2 to server the static content from inside the jar and than S2 will write the header to tell the browser to cache the content so that for subsequent request browser need not to fetch the content from the server.This is a standard way to speed up a website and it has nothing to do with browser back button.

When you log-out the user make sure that you invalidate the session.what you are facing is the cached copy of the browser.

When you requesting a copy of page browser checking if the same is with its cache and if yes, in place of requesting the server its serving the content from its cache.Just click on any link which required user to be logged in and you will see that link is not working since in that case browser is requesting the server for the content.

If you want to control this,you can set the cache control headers to request browser not to cache your content something like

response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");

Please go through this thread for details

how-to-disable-back-button-using-struts2

Upvotes: 1

Related Questions