JSFStaticResourcesFilter
package com.blogspot.na5cent.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; /** * * @author redcrow */ @WebFilter(urlPatterns = "/javax.faces.resource/*") public class JSFStaticResourcesFilter implements Filter { @Override public void init(FilterConfig fc) throws ServletException { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { HttpServletResponse httpResponse = (HttpServletResponse) response; HttpServletResponseWrapper httpResponseWrapper = new HttpServletResponseWrapper(httpResponse) { @Override public void setHeader(String name, String value) { if (!name.equalsIgnoreCase("ETag") && !name.equalsIgnoreCase("Expires") && !name.equalsIgnoreCase("Last-Modified") && !name.equalsIgnoreCase("Pragma") && !name.equalsIgnoreCase("Date") && !name.equalsIgnoreCase("Cache-Control")) { super.setHeader(name, value); } } }; httpResponseWrapper.addHeader("Cache-Control", "max-age=604800"); //60 * 60 * 24 * 7 = 1 week chain.doFilter(request, httpResponseWrapper); } @Override public void destroy() { } }thank you very much : http://stackoverflow.com/questions/7895196/how-do-delete-a-http-response-header
ไม่มีความคิดเห็น:
แสดงความคิดเห็น