Paul,
I started the thread and I do recall posting a concluding message perhaps as
much as a couple of weeks later.
After believing I had struck upon the perfect set of headers to set:
data.getResponse().setHeader("Cache-Control", "no-cache"); //HTTP 1.1
data.getResponse().setHeader("Pragma", "no-cache"); //HTTP 1.0
data.getResponse().setDateHeader("Expires", 0); //prevents caching at the
proxy server
... and the best way to do it:
use a pull tool method to execute the above statements in my default
layout.
... I discovered that my client site was still experiencing problems where
old data was being displayed.
As a result I concluded that the extension to TemplateLink was the only
solution that would guarantee a refresh every time. The implementation I
settled upon follows. The nocacheid path info is added in getURI() and
toString() so that it works for setAction() as well as setPage().
import java.util.Date;
import org.apache.turbine.util.template.*;
/**
* Title: TemplateLinkEx<p>
* Description: Extension to TurbineLink that provides for unique URLs to
* force caches to retrieve the page every time. This is implemented in a
* very bad way, but then TemplateLink itself is pretty shocking in that it
* breaks the toString() contract by altering the value of the object.<p>
*/
public class TemplateLinkEx extends TemplateLink
{
private static final String NOCACHE = "nocacheid";
public String getURI()
{
super.addPathInfo(NOCACHE, new java.util.Date().getTime());
String result = super.getURI();
super.removePathInfo(NOCACHE);
return result;
}
public String toString()
{
super.addPathInfo(NOCACHE, new java.util.Date().getTime());
return super.toString();
}
I still set the headers so that I don't fill well behaved caches with pages
that will never be used again.
HTH,
Scott
> From: Paul Szego <[EMAIL PROTECTED]>
>
> Hi,
>
> I've read through this thread twice now, and although there's a lot of
> discussion there doesn't seem to be any conclusion.
>
> Does anyone *know* how to do this, or is it a case of trying every
> approach listed there and see what works?
>
> Regards, PaulS.
>
>
> Heiko Braun wrote:
>> take a look here:
>>
>> http://www.mail-archive.com/turbine-user%40jakarta.apache.org/msg02623.html
>>
>> /heiko
>>
>> Am Fre, 2002-02-22 um 13.13 schrieb Christian Asmussen:
>>
>>> I've had a problem with some browsers like opera and IE for the example
>>> app created by turbine 2.1. I clicked on the "Home" link of the menu and
>>> was not logged in, so the Login screen apears. After login in, I tryied
>>> the same link again, but the browser had cached a copy of login, so I was
>>> redirected to the login screen again. Of course, by clicking on the
>>> reload button the problem was solved. The thing is a regular user won't
>>> do that. How can I avoid these caches? Should I set an expires now for
>>> every page?
>>>
>>> --
>>> "If we did all the things we are capable of,
>>> we would literally astound ourselves"
>>> - Thomas Edison
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:
>>> <mailto:[EMAIL PROTECTED]>
>>> For additional commands, e-mail:
>>> <mailto:[EMAIL PROTECTED]>
>>>
>
>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>