Monday, January 11, 2021

Re: app not reload from android chrome

Hey Pierre,
You can use a special web filter for better handling of caching. 
Here is an example similar to what I use on my projects, 

Add the following to your web.xml
<filter>
<filter-name>gwtCacheControlFilter</filter-name>
<filter-class>com.acme.server.GWTCacheControlFilter</filter-class>
<init-param>
<param-name>Cache-Control</param-name>
<param-value>max-age=31536000, public</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>gwtCacheControlFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

And the doFilter method of your filter class would be something like
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException,
ServletException {

HttpServletRequest httpRequest = (HttpServletRequest) request;
String requestURI = httpRequest.getRequestURI();

if (requestURI.contains(".nocache.")) {
Date now = new Date();
HttpServletResponse httpResponse = (HttpServletResponse) response;
httpResponse.setDateHeader("Date", now.getTime());
// one day old
httpResponse.setDateHeader("Expires", now.getTime() - 86400000L);
httpResponse.setHeader("Pragma", "no-cache");
httpResponse.setHeader("Cache-control", "no-cache, no-store, must-revalidate");
} else if (requestURI.contains(".cache.")) {
HttpServletResponse httpResponse = (HttpServletResponse) response;
// one day old
httpResponse.setHeader("Cache-Control", "public, max-age=31536000");
httpResponse.setDateHeader("Expires", DateUtil.addDays(new Date(), 365).getTime());
}

filterChain.doFilter(request, response);
}
-Selcuk


On Mon, Jan 11, 2021 at 1:35 PM pierre...@gmail.com <pierregilquin@gmail.com> wrote:
Hi,
I have a gwt app developed with gwt-material but I assume it's not relevant for this problem.
The app is served by Tomcat.
Everything is fine with PC/iphone/iPad but with android after deploying a new app, the old one is still showned. The nocache mecanism doesnot work in android chrome.
Removing the cache works, but I cannot asks that to my users.

Any hint how can I force the browser  to reload the app from server for theses mobiles ?
Thanks in advance
Pierre

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/cf24a086-3c9e-4488-9ab8-200402a38b4bn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CA%2Bw5W1sS-NhKOH66g79zw0GkRwDCMWDBDxGTu-O2pcSKqa5iPw%40mail.gmail.com.

No comments:

Post a Comment