myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Hinterndorfer" <martin.hinterndor...@irian.at>
Subject Re: [myfaces1.1.5][facelets 1.1.12] desable IE7 cache?
Date Mon, 18 Feb 2008 12:05:17 GMT
Hi!

As far as I know, you can use 2 mechanisms to turn off caching:

1. Entry in the html-header tag:
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <!-- or charset=iso-8859-1-->
    <meta http-equiv="expires" content="0"/>
    <meta http-equiv="cache-control" content="no-store"/>
    <meta http-equiv="pragma" content="no-cache"/>
</head>

This might not be read by proxies and some browsers so it helps to
additionally use the solution of setting the parameters in the HttpResponse:

2. As a Phase-Listener:

in the beforePhase of the RenderResponse phase:

public class CacheControlPhaseListener
        implements PhaseListener {

   public void beforePhase(PhaseEvent event) {
        FacesContext facesContext = event.getFacesContext();
        CacheControlPhaseListenerConfig config =
getCacheControlPhaseListenerConfig();
        String viewId = facesContext.getViewRoot().getViewId();

        HttpServletResponse servletResponse
                = (HttpServletResponse) facesContext.getExternalContext
().getResponse();
        servletResponse.setHeader("expires", "0"); //is interpreted by most
browsers as "never cache page"
        servletResponse.setHeader("cache-control", "no-store");
        servletResponse.setHeader("pragma", "no-cache");
    }

    public void afterPhase(PhaseEvent event) {
        //do nothing
    }

    public PhaseId getPhaseId() {
        return PhaseId.RENDER_RESPONSE;
    }
}
Don't forget to register your phase-listener-class in the faces-config.xml:
<lifecycle>
    <phase-listener>CacheControlPhaseListener</phase-listener>
</lifecycle>


The combination of both approaches should turn off caching completely.

Kind regards,

Martin



2008/2/16, Mathias Walter <mathias.walter@gmx.net>:
>
> Hi,
>
> > Maybe setting the http cache headers?
>
> I tried all variants and verified it with FireBug. IE ignores these
> settings. But I've the problems only with backward/forward navigation.
>
> --
> Kind regards,
> Mathias
>
> >
> > Scott
> >
> > Mathias Walter wrote:
> > > Hi,
> > >
> > > You don't have a real name. So don't expect any answer!
> > >
> > > But, I experienced similar problems with IE6 and Trinidad
> > too and could not
> > > solve it. With FireFox it works well.
> > >
> > > --
> > > Kind regards,
> > > Mathias
> > >
> > >
> > >> -----Original Message-----
> > >> From: lmk [mailto:lotfi65@yahoo.fr]
> > >> Sent: Thursday, February 14, 2008 3:11 PM
> > >> To: users@myfaces.apache.org
> > >> Subject: [myfaces1.1.5][facelets 1.1.12] desable IE7 cache?
> > >>
> > >>
> > >>
> > >> hello,
> > >> I have some  issues using  ajax features with myfaces and facelets,
> > >> it seems that IE7 keep  xml request component on cache
> > >> how to avoid, disable using IE cache?
> > >>
> > >> environement: myfaces 1.1.5,facelets 1.1.13,rich-faces 1.1.4.
> > >>
> > >> regards!
> > >> --
> > >> View this message in context:
> > >> http://www.nabble.com/-myfaces1.1.5--facelets-1.1.12--desable-
> > >>
> > > IE7--cache--tp15480674p15480674.html
> > > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> > >
> > >
>
>

Mime
View raw message