Good point Jens. Here's some handy code that works well for me:
In the HttpServlet that servers up the index.html file:
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
String serverVersion =
[LOAD YOUR SERVER VERSION]
String quotedETag = "\"" + serverVersion + "\"";
response.setHeader("ETag", quotedETag);
response.setHeader("Cache-Control", "no-cache, must-revalidate");
String ifNoneMatch = request.getHeader("If-None-Match");
// The browser has the latest version
if (quotedETag.equals(ifNoneMatch)) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); // 304 Not Modified
}
// The browser needs the latest version
else {
String html = [LOAD YOUR HTML]
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
response.getWriter().append(html);
}
}
You need a serverVersion somehow. If using Google App Engine, you can do System.getenv("GAE_VERSION"); otherwise, it's up to you how you get it and make it unique for each deploy.