0

I am creating a project in vaadin which runs on Tomcat, but the question concerns generally a java web-application. The application consists of a number of modules, which all together comprise the application. I want to adjust it, so as the way the application runs to be determined by the url. Therefore I attach a parameter to the url, the url seems namely as:

http:myproject/anything/foo?mode=sth.

I extract the parameter in the method onRequestStart():

String param = request.getParameter("mode");

I build the application according to the parameter. I.e. parameter a1 shows only module a1, parameter a2 only module a2,... and parameter normal the whole application. However I have a problem with the browser cache especially on parameter "normal". After running first time with this parameter, all the next times the browser does not "realize" a new request and shows the application from the cache, meaning the last module showed. Strangely on the other parameters I have not yet noticed this problem. Nevertheless, it is still not reliable and in order to make it certainly reliable I have to avoid browser cache. What could be a solution? I have found that one solution is to add a timestamp on the url, which must each time change so that it reads always a new url and makes a new request. How could I attach it though in a java application?

1 Answer 1

1

Set the appropriate cache control headers for your HttpServletResponse.

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

If you need to do this for all your pages, better implement this as a Filter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.