java - Disable filter based on response -


i have client caching disabling filter mapped urls.

now have disable filter , allow caching when response has other html.

my current filter code follows:

public class nocachefilter implements filter{      @override     public void destroy() {}      @override     public void dofilter(servletrequest request, servletresponse response,             filterchain filterchain) throws ioexception, servletexception {         httpservletresponse httpresponse = (httpservletresponse) response;         httpresponse.setheader("pragma", "no-cache");         httpresponse.setheader("cache-control","no-cache,no-store,max-age=0,s-maxage=0,must-revalidate,proxy-revalidate,private,max-stale=0,post-check=0");         httpresponse.setdateheader("expires", 0l);         filterchain.dofilter(request, response);     }      @override     public void init(filterconfig arg0) throws servletexception {}  } 

note: people want know why doing - have paged generate pdf. take pdf file , flush output stream. in ie8, flush code doesn't work , logs show the client closed connetion immaturely...cannot write committed response.... when caching enabled, pdf written client normally; without issue. separate requirement of existing app not allow caching of page on client.

did try simple this:

@override public void dofilter(servletrequest request, servletresponse response,         filterchain filterchain) throws ioexception, servletexception {     httpservletresponse httpresponse = (httpservletresponse) response;     filterchain.dofilter(request, response);     if(response.getcontenttype().indexof("text/html")>-1){         httpresponse.setheader("pragma", "no-cache");         httpresponse.setheader("cache-control","no-cache,no-store,max-age=0,s-maxage=0,must-revalidate,proxy-revalidate,private,max-stale=0,post-check=0");         httpresponse.setdateheader("expires", 0l);     } } 

it don't disable filter, @ least filter don't when response not html.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -