[jboss-user] [JBoss Seam] - Re: Disabling browser cache ???

terryb do-not-reply at jboss.com
Thu Oct 11 21:44:45 EDT 2007


Thanks. I tried following? it executs but it gets invoked many time for each  page. I think once or so for every included xhtml, since my page has template, headers, footer, menu bars in seperate files. I guess that is normal...


public class NoCachePhaseListener implements PhaseListener { 
  | 
  |     public PhaseId getPhaseId() {
  |         return PhaseId.RENDER_RESPONSE; 
  |     } 
  | 
  |     public void afterPhase(PhaseEvent phaseEvent) { 
  |     } 
  | 
  |     public void beforePhase(PhaseEvent phaseEvent) {
  |         
  |         FacesContext facesContext = phaseEvent.getFacesContext(); 
  |         HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse(); 
  |         
  |         try{ 
  |             response.setHeader("Cache-Control", "no-cache, must-revalidate");
  |             response.setDateHeader("Expires", 0L);
  |             response.setHeader("Pragma", "No-cache");
  |         }catch(NullPointerException npe){ 
  |             System.out.println("Null http response, no action on cache-control"); 
  |         } 
  | 
  |     } 
  | } 


faces-config.xml:

<lifecycle> 
  |     <phase-listener>au.edu.tisc.util.NoCachePhaseListener</phase-listener>
  | </lifecycle> 




View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4094332#4094332

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4094332



More information about the jboss-user mailing list