You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Shawn Church <sh...@boxity.com> on 2004/09/14 20:38:35 UTC

Response headers and cache control

I need to ensure one page of my application is never cached, but 
setting the response headers in pageBeginRender does not seem to work.  
Is this the correct place?  In pageBeginRender(), I've tried this:

HttpServletResponse response = event.getRequestCycle().getRequestContext
().getResponse();
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Cache-Control", "must-revalidate");
response.setHeader("Expires", "0");
response.setHeader("Pragma", "no-cache");

and other variations (such as setting an Expires timestamp), but my 
browser is still caching this page. 

Any suggestions?

Thanks,
Shawn




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Response headers and cache control

Posted by Shawn Church <sh...@boxity.com>.
Jamie,

I initially looked at Shell, hoping there would be some Tapestry-
provided solution for this.  I implemented my own Shell component, and 
yes this was more effective for controlling the response headers.

Part of my problem also related to forcing the browser reload of 
certain page images (the images are server generated, but are named 
similarly between requests).  I've run into this before, and the only 
way I know of to force an image reload is to pass a random argument 
after the image (eg - image.gif?12345).  This seems to be more of an IE 
problem than with other browsers.

Thanks,
Shawn


Quoting Jamie Orchard-Hays <ja...@dang.com>:

> have a look at Shell.java's renderComponent() method. In that is
> getDelegate() (returns type IRender). If you can figure out a way to
> access
> this, you'll solve your problem.
> 
> Jamie
> ----- Original Message ----- 
> From: "Shawn Church" <sh...@boxity.com>
> To: <ta...@jakarta.apache.org>
> Sent: Tuesday, September 14, 2004 2:38 PM
> Subject: Response headers and cache control
> 
> 
> > I need to ensure one page of my application is never cached, but
> > setting the response headers in pageBeginRender does not seem to
> work.
> > Is this the correct place?  In pageBeginRender(), I've tried this:
> >
> > HttpServletResponse response =
> event.getRequestCycle().getRequestContext
> > ().getResponse();
> > response.setHeader("Cache-Control", "no-cache");
> > response.setHeader("Cache-Control", "no-store");
> > response.setHeader("Cache-Control", "must-revalidate");
> > response.setHeader("Expires", "0");
> > response.setHeader("Pragma", "no-cache");
> >
> > and other variations (such as setting an Expires timestamp), but
> my
> > browser is still caching this page.
> >
> > Any suggestions?
> >
> > Thanks,
> > Shawn
> >
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Direct link stale session

Posted by Terry Poot <tp...@goldenvoid.com>.
James Sherwood wrote:

>I had the link correct, it worked fine as long as there was a session, its
>when there was no session it gave a stale link.
>  
>
And that will always be the case, it's the nature of a DirectLink. 
That's why you need to use an ExtermalLink. A direct link is always 
relative to an existing session, and if there isn't one, you'll get the 
exception. ExternalLink is specifically designed to be accessed 
"external" to the web app: from an email, a book mark, a search engine, 
another web page outside the web app, etc. What you're trying to do is 
precisely the sort of thing that ExternalLink is for.

>I have the direct link set to statless as well(tried it both ways)
>
>----- Original Message ----- 
>From: "Holger Stephan" <tm...@frogleg.net>
>To: "Tapestry users" <ta...@jakarta.apache.org>
>Sent: Thursday, September 16, 2004 12:37 PM
>Subject: Re: Direct link stale session
>
>
>  
>
>>James, in your confirmation mail use an ExternalLink, with the
>>parameter(s) already encoded. You can either do this yourself (by
>>checking out how service parameters are handled, easy enough) or by
>>calling AbstractService.constructLink.
>>
>>- Holger
>>
>>On Thu, 2004-09-16 at 04:28, James Sherwood wrote:
>>    
>>
>>>I am trying to make a confermation page where I email the user a link
>>>      
>>>
>and
>  
>
>>>they click on it to confirm something.
>>>
>>>I made it a directlink in the page and in the java I just pull in the
>>>service paramater which is a long random string.
>>>
>>>It all works fine as long as they have went to a page on the site
>>>      
>>>
>already
>  
>
>>>but if they try to just click on the link it opens a new browser and
>>>      
>>>
>gives a
>  
>
>>>stale link
>>>
>>>Any ideas why or a different way to accomplish this?
>>>
>>>Thanks,
>>>James
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Direct link stale session

Posted by James Sherwood <js...@romulin.com>.
I had the link correct, it worked fine as long as there was a session, its
when there was no session it gave a stale link.

I have the direct link set to statless as well(tried it both ways)

----- Original Message ----- 
From: "Holger Stephan" <tm...@frogleg.net>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, September 16, 2004 12:37 PM
Subject: Re: Direct link stale session


> James, in your confirmation mail use an ExternalLink, with the
> parameter(s) already encoded. You can either do this yourself (by
> checking out how service parameters are handled, easy enough) or by
> calling AbstractService.constructLink.
>
> - Holger
>
> On Thu, 2004-09-16 at 04:28, James Sherwood wrote:
> > I am trying to make a confermation page where I email the user a link
and
> > they click on it to confirm something.
> >
> > I made it a directlink in the page and in the java I just pull in the
> > service paramater which is a long random string.
> >
> > It all works fine as long as they have went to a page on the site
already
> > but if they try to just click on the link it opens a new browser and
gives a
> > stale link
> >
> > Any ideas why or a different way to accomplish this?
> >
> > Thanks,
> > James
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Direct link stale session

Posted by Holger Stephan <tm...@frogleg.net>.
James, in your confirmation mail use an ExternalLink, with the
parameter(s) already encoded. You can either do this yourself (by
checking out how service parameters are handled, easy enough) or by
calling AbstractService.constructLink.

- Holger

On Thu, 2004-09-16 at 04:28, James Sherwood wrote:
> I am trying to make a confermation page where I email the user a link and
> they click on it to confirm something.
> 
> I made it a directlink in the page and in the java I just pull in the
> service paramater which is a long random string.
> 
> It all works fine as long as they have went to a page on the site already
> but if they try to just click on the link it opens a new browser and gives a
> stale link
> 
> Any ideas why or a different way to accomplish this?
> 
> Thanks,
> James


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Direct link stale session

Posted by James Sherwood <js...@romulin.com>.
I am trying to make a confermation page where I email the user a link and
they click on it to confirm something.

I made it a directlink in the page and in the java I just pull in the
service paramater which is a long random string.

It all works fine as long as they have went to a page on the site already
but if they try to just click on the link it opens a new browser and gives a
stale link

Any ideas why or a different way to accomplish this?

Thanks,
James



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Response headers and cache control

Posted by Lars Hoss <wo...@acidware.net>.
Hi!

Regarding IE you should add the following at the end of your page:

...
</body>
<head>
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
</head>
</html>

This is a known bug in IE:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;222064

Yours,
Lars

Am 16.09.2004 um 09:24 schrieb Eli Doran:

> Servlet API 2.2 added HttpServletResponse.addHeader(...). You should 
> use that for calls after the initial setHeader("Cache-Control", ...). 
> Calling setHeader(...) again with the same name overwrites the 
> previous value. In Java Enterprise Best Practices is suggests using:
>
> response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
> response.setHeader("Cache-Control", "no-store, no-cache, 
> must-revalidate");
> response.addHeader("Cache-Control", "post-check=0, pre-check=0");
> response.setHeader("Pragma", "no-cache");
>
> Why use two calls for 'Cache-Control'? You don't have to but I thought 
> I'd type it as shown in the book.
>
> happy coding,
> eli
>
> Jamie Orchard-Hays wrote:
>
>> have a look at Shell.java's renderComponent() method. In that is
>> getDelegate() (returns type IRender). If you can figure out a way to 
>> access
>> this, you'll solve your problem.
>>
>> Jamie
>> ----- Original Message ----- From: "Shawn Church" <sh...@boxity.com>
>> To: <ta...@jakarta.apache.org>
>> Sent: Tuesday, September 14, 2004 2:38 PM
>> Subject: Response headers and cache control
>>
>>
>>
>>> I need to ensure one page of my application is never cached, but
>>> setting the response headers in pageBeginRender does not seem to 
>>> work.
>>> Is this the correct place?  In pageBeginRender(), I've tried this:
>>>
>>> HttpServletResponse response = 
>>> event.getRequestCycle().getRequestContext
>>> ().getResponse();
>>> response.setHeader("Cache-Control", "no-cache");
>>> response.setHeader("Cache-Control", "no-store");
>>> response.setHeader("Cache-Control", "must-revalidate");
>>> response.setHeader("Expires", "0");
>>> response.setHeader("Pragma", "no-cache");
>>>
>>> and other variations (such as setting an Expires timestamp), but my
>>> browser is still caching this page.
>>>
>>> Any suggestions?
>>>
>>> Thanks,
>>> Shawn
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: 
>>> tapestry-user-help@jakarta.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
"Stil ist die Fähigkeit, komplizierte Dinge einfach zu sagen - nicht 
umgekehrt." -- Cocteau, Jean


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Response headers and cache control

Posted by Eli Doran <el...@elidoran.com>.
Servlet API 2.2 added HttpServletResponse.addHeader(...). You should use 
that for calls after the initial setHeader("Cache-Control", ...). 
Calling setHeader(...) again with the same name overwrites the previous 
value. In Java Enterprise Best Practices is suggests using:

response.setHeader("Expires", "Sat, 6 May 1995 12:00:00 GMT");
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
response.setHeader("Pragma", "no-cache");

Why use two calls for 'Cache-Control'? You don't have to but I thought 
I'd type it as shown in the book.

happy coding,
eli

Jamie Orchard-Hays wrote:

>have a look at Shell.java's renderComponent() method. In that is
>getDelegate() (returns type IRender). If you can figure out a way to access
>this, you'll solve your problem.
>
>Jamie
>----- Original Message ----- 
>From: "Shawn Church" <sh...@boxity.com>
>To: <ta...@jakarta.apache.org>
>Sent: Tuesday, September 14, 2004 2:38 PM
>Subject: Response headers and cache control
>
>
>  
>
>>I need to ensure one page of my application is never cached, but
>>setting the response headers in pageBeginRender does not seem to work.
>>Is this the correct place?  In pageBeginRender(), I've tried this:
>>
>>HttpServletResponse response = event.getRequestCycle().getRequestContext
>>().getResponse();
>>response.setHeader("Cache-Control", "no-cache");
>>response.setHeader("Cache-Control", "no-store");
>>response.setHeader("Cache-Control", "must-revalidate");
>>response.setHeader("Expires", "0");
>>response.setHeader("Pragma", "no-cache");
>>
>>and other variations (such as setting an Expires timestamp), but my
>>browser is still caching this page.
>>
>>Any suggestions?
>>
>>Thanks,
>>Shawn
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Response headers and cache control

Posted by Jamie Orchard-Hays <ja...@dang.com>.
have a look at Shell.java's renderComponent() method. In that is
getDelegate() (returns type IRender). If you can figure out a way to access
this, you'll solve your problem.

Jamie
----- Original Message ----- 
From: "Shawn Church" <sh...@boxity.com>
To: <ta...@jakarta.apache.org>
Sent: Tuesday, September 14, 2004 2:38 PM
Subject: Response headers and cache control


> I need to ensure one page of my application is never cached, but
> setting the response headers in pageBeginRender does not seem to work.
> Is this the correct place?  In pageBeginRender(), I've tried this:
>
> HttpServletResponse response = event.getRequestCycle().getRequestContext
> ().getResponse();
> response.setHeader("Cache-Control", "no-cache");
> response.setHeader("Cache-Control", "no-store");
> response.setHeader("Cache-Control", "must-revalidate");
> response.setHeader("Expires", "0");
> response.setHeader("Pragma", "no-cache");
>
> and other variations (such as setting an Expires timestamp), but my
> browser is still caching this page.
>
> Any suggestions?
>
> Thanks,
> Shawn
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org