I wasn't aware of the <init-param> solution -- is that new with Struts
1.1?

Regardless, we solve this problem by overriding the process method of
the ActionServlet and setting some headers prior to calling super.
Something like this:

    protected void process(HttpServletRequest request,
                           HttpServletResponse response)
        throws java.io.IOException, ServletException
    {
        // We're dynamic, so caching is disabled
        response.setHeader("Cache-Control", "no-cache");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Expires", "-1");

        super.process(request, response);
    }

That works for all the popular browsers.  I think it's only the
"Expires" that actually works, though.  The others are there due to
programmer superstition...  :-)

-- Jim

Antony Stace <[EMAIL PROTECTED]> writes:

> Hi Folks
> 
> I want to prevent caching of all pages in my webapp.  What is the easiest way for me 
>to append a dummy variable onto
> all the addresses which appear in the users browsers address bar, ie
> 
> http://localhost/testWebApp?rand=7A98SDF7ASD9YFBA9D8S7FBASDBFASBFASDFSADFASD
> 
> I don't want to rely on setting
> 
> <init-param>
>     <param-name>nocache</no-param>
>     <param-value>true</no-param>
> </init-param>
> 
> in my web.xml file since I have read in quite a few places that some browsers do not 
>respect the 
> 
> <meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
> 
> directive which is sent in a http message from a server to browser.
> 
> 
> 
> Cheers
> 
> Tony
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

-- 
Jim Crossley
http://www.lads.com/~jim

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to