In my Spring JSF facelets web application in Jboss6 server I need to make sure certain web pages do not get cached by the web browser for security reasons. And it should work as cross browser as well. I found out when I ran the test in YSlow plugin in firefox the below recommendations.
In my web application I have a Phaselistener set to disable cache as well. But I still couldn't figure why these results are given by YSlow and I want to know how to resolve this issue by setting the far future expiration date to those static components and improve the performance of this page as well.
cache control phaselistener
public class CacheControlPhaseListener implements PhaseListener {
/**
*
*/
private static final long serialVersionUID = 1L;
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
public void afterPhase(PhaseEvent event) {
}
public void beforePhase(PhaseEvent event) {
FacesContext facesContext = event.getFacesContext();
HttpServletResponse response = (HttpServletResponse) facesContext
.getExternalContext().getResponse();
response.addHeader("Pragma", "no-cache");
response.addHeader("Cache-Control", "no-cache");
response.addHeader("Cache-Control", "no-store");
response.addHeader("Cache-Control", "must-revalidate");
response.addHeader("Expires", "Mon, 8 Aug 2006 10:00:00 GMT");
}
}
In faceconfig
<lifecycle>
<phase-listener id="nocache">com.company.jsf.listener.CacheControlPhaseListener</phase-listener>
</lifecycle>
the http header
After adding future dates YSlow still display the following,