/** * Make this response non-cacheable */ public void disableCaching() { setDateHeader("Date", System.currentTimeMillis()); setDateHeader("Expires", 0); setHeader("Pragma", "no-cache"); setHeader("Cache-Control", "no-cache, no-store"); } }
/** * Subclasses can override this to set there headers when the resource is being served. By * default 2 headers will be set if the Resource is cacheable * * <pre> * response.setDateHeader("Expires", System.currentTimeMillis() + (3600 * 1000)); * response.setHeader("Cache-Control", "max-age=" + 3600); * </pre> * * So if a resource wants to control this or doesn't want to set this info it should override * this method and don't call super. * * @param response * The WebResponse where set(Date)Header can be called on. */ protected void setHeaders(WebResponse response) { if (isCacheable()) { // If time is set also set cache headers. response.setDateHeader("Expires", System.currentTimeMillis() + (getCacheDuration() * 1000)); response.setHeader("Cache-Control", "max-age=" + getCacheDuration()); } else { response.setHeader("Cache-Control", "no-cache, must-revalidate"); } }
/** * @see org.apache.wicket.IRequestTarget#respond(org.apache.wicket.RequestCycle) */ public void respond(RequestCycle requestCycle) { WebResponse response = (WebResponse)requestCycle.getResponse(); final String encoding = Application.get() .getRequestCycleSettings() .getResponseRequestEncoding(); // Set content type based on markup type for page response.setCharacterEncoding(encoding); response.setContentType("text/xml; charset=" + encoding); // Make sure it is not cached by a client response.setDateHeader("Expires", System.currentTimeMillis()); response.setHeader("Cache-Control", "no-cache, must-revalidate"); response.setHeader("Pragma", "no-cache"); response.write("<?xml version=\"1.0\" encoding=\""); response.write(encoding); response.write("\"?><ajax-response></ajax-response>"); }
response.setDateHeader("Expires", System.currentTimeMillis() + (getCacheDuration() * 1000L)); if (Application.get()