tags:

views:

251

answers:

1

Hi I write 2 GWT module and compile it. I want locate ***.nocache.js files into a html file.

+1  A: 

You need to include the .nocache.js files as scripts in your HTML file:

<script language="javascript" src="com.acme.gwt.Module.nocache.js"></script>
<script language="javascript" src="com.acme.gwt.Module2.nocache.js"></script>

You also need to configure your web server to add headers to requests to .nocache. files to prevent caching by client browsers. If these files are cached, clients won't see new versions of your application easily. A web server portable way to do this is to use a servlet filter:

public class CacheHeaderFilter implements Filter {

    public void doFilter(ServletRequest req, ServletResponse res,
            FilterChain filterChain) throws IOException, ServletException {
        String uri = ((HttpServletRequest)req).getRequestURI();
        if (uri.contains(".cache.")) {
            ((HttpServletResponse)res).setDateHeader("Expires",
                System.currentTimeMillis() + 31536000000L);
        } else if (uri.contains(".nocache.")) {
            ((HttpServletResponse)res).setHeader("Cache-Control", "no-cache");
        }
        filterChain.doFilter(req, res);
    }
...
}

Reference this in web.xml:

<filter>
    <filter-name>cacheHeaderFilter</filter-name>
    <filter-class>com.acme.gwt.server.CacheHeaderFilter</filter-class>
</filter>
David Tinker
watch out that these two gwt modules dont interfer with each other. Usually, gwt modules assumes it is the only gwt module on the page, and so things like the history iframe might be munged.
Chii