title: How to set Filter to be applied for content-type "html/text" ONLY?
body: <p>I wrote following code.</p>
  
  <pre><code>import javax.servlet.*;
  import javax.servlet.http.HttpServletResponse;
  import java.io.IOException;
  import java.util.Date;
  
  public class CacheFilter implements Filter {
  
  public void doFilter(ServletRequest request, ServletResponse response,
                       FilterChain chain) throws IOException, ServletException {
  
      HttpServletResponse resp = (HttpServletResponse) response;
      resp.setHeader("Cache-Control", "no-store, no-cache,must-revalidate,max-age=0");
      resp.setHeader("Pragma", "no-cache");
  
      chain.doFilter(request, response);
  }
  
  public void destroy() {
  //delegate.destroy();
  }
  public void init(FilterConfig filterConfig) {
  //delegate.destroy();
  }
  }
  </code></pre>
  
  <p>and here's the maping code in web.xml file</p>
  
  <pre><code>  &lt;filter&gt;
       &lt;filter-name&gt;CacheFilter&lt;/filter-name&gt;
       &lt;filter-class&gt;com.util.CacheFilter&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;CacheFilter&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
      &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>This thing works but this filter gets applied for all the content, thus slowing my site's performance. I want this filter to be applied for content type "text/html" only. This can be easily achieved through <strong>ExpiresFilter</strong> like this</p>
  
  <pre><code> &lt;init-param&gt;
       &lt;param-name&gt;ExpiresByType text/html&lt;/param-name&gt;
       &lt;param-value&gt;access plus 0 seconds&lt;/param-value&gt;
  &lt;/init-param&gt;
  </code></pre>
  
  <p>but how to achieve it in this code?
  I'd appreciate your earliest help.</p>