Closes #146: no cache

This commit is contained in:
bgamard 2017-11-09 13:36:10 +01:00
parent 244ddc7ce2
commit f57cf46313

View File

@ -12,6 +12,7 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest; import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.HttpHeaders;
import com.lowagie.text.FontFactory; import com.lowagie.text.FontFactory;
import org.apache.log4j.Level; import org.apache.log4j.Level;
@ -97,6 +98,7 @@ public class RequestContextFilter implements Filter {
tx.begin(); tx.begin();
try { try {
addCacheHeaders(response);
filterChain.doFilter(request, response); filterChain.doFilter(request, response);
} catch (Exception e) { } catch (Exception e) {
ThreadLocalContext.cleanup(); ThreadLocalContext.cleanup();
@ -151,4 +153,15 @@ public class RequestContextFilter implements Filter {
ThreadLocalContext.cleanup(); ThreadLocalContext.cleanup();
} }
/**
* Add no-cache header.
*
* @param response Response
*/
private void addCacheHeaders(ServletResponse response) {
HttpServletResponse r = (HttpServletResponse) response;
r.addHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
r.addHeader(HttpHeaders.EXPIRES, "0");
}
} }