4d463c3b by Adam Heath

Make a method that can be used in multiple places for setting the

no-cache headers.

Refs: #7593
1 parent a72036e1
...@@ -265,6 +265,20 @@ public class DirectControlServlet extends HttpServlet { ...@@ -265,6 +265,20 @@ public class DirectControlServlet extends HttpServlet {
265 return file; 265 return file;
266 } 266 }
267 267
268 protected void setResponseNoCache() {
269 // Set to expire far in the past.
270 response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
271
272 // Set standard HTTP/1.1 no-cache headers.
273 response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
274
275 // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
276 response.addHeader("Cache-Control", "post-check=0, pre-check=0");
277
278 // Set standard HTTP/1.0 no-cache header.
279 response.setHeader("Pragma", "no-cache");
280 }
281
268 protected void processRequest() throws Exception { 282 protected void processRequest() throws Exception {
269 Map<String, Object> context = new HashMap<String, Object>(); 283 Map<String, Object> context = new HashMap<String, Object>();
270 284
...@@ -426,17 +440,7 @@ public class DirectControlServlet extends HttpServlet { ...@@ -426,17 +440,7 @@ public class DirectControlServlet extends HttpServlet {
426 } 440 }
427 response.setStatus(statusCode); 441 response.setStatus(statusCode);
428 442
429 // Set to expire far in the past. 443 setResponseNoCache();
430 response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
431
432 // Set standard HTTP/1.1 no-cache headers.
433 response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
434
435 // Set IE extended HTTP/1.1 no-cache headers (use addHeader).
436 response.addHeader("Cache-Control", "post-check=0, pre-check=0");
437
438 // Set standard HTTP/1.0 no-cache header.
439 response.setHeader("Pragma", "no-cache");
440 444
441 if ("JSON".equals(outputHandler)) { 445 if ("JSON".equals(outputHandler)) {
442 response.setContentType("application/x-json"); 446 response.setContentType("application/x-json");
......