You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by sunmoor007 <su...@gmail.com> on 2011/03/15 08:27:28 UTC

Re: Tapestry 5 - cache issue when accessed via proxy

Hi All

we have checked the proxy logs and issue seems to be because of the presence
of proxy server. Proxy server caches the url. As we dont have the search
criteria in the url, the same url is getting passed. We modified few
settings in proxy server so that our app url doesnt get cached. It worked
fine without any issue, though changing proxy server setting is not a
feasible solution considering the fact that this application will be used by
various users across the globe.

I believe the only way to prevent the proxy server caching links is to have
a dynamic parameter in url so that everytime proxy server identifies it as a
new request and hence it wont cache.

Is there a way in Tapestry to dynamically include a parameter in url. This
dynamic parameter, say a timezone will be appended for each and every
request url(including redirected one's).

Would really appreciate if guys can provide your inputs on the same.

Thanks
Sundar


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3681523.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by sunmoor007 <su...@gmail.com>.
Hi All

We have managed to resolve the URL issue using the LinkCreationHubinterface.
Instead of build method, we need to have a decorator method for
LinkCreationHub. I have observed that LinkCreationHub is created by
TapestryModule, hence we just need to have a decorator method to add our
listener to existing listener.

public LinkCreationHub decorateLinkCreationHub(LinkCreationHub hub)
{
LinkCreationListener listener = new MyLinkCreationListenerImpl();
hub.addListener(listener);
return hub;
}

This fix has ensured that all page, component event links are appended with
a dynamic paramter in url. Thanks to all who have provided their valuable
suggestion. Special thanks to Thiago for giving the hint about
LinkCreationListener.

Thanks
Sundar

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p4250743.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by sunmoor007 <su...@gmail.com>.
Hi Martin

We did try setting the cache headers but it didnt work. Moreover this
application works fine when accessed directly. The problem comes only when
the application is accessed via proxy server. Thats the reason i have
suspected the URL.

We did a workaround at proxy server setting level so that all requests with
a particular path wont be cached by proxy server. This did work but we are
looking forward for a fix from application point of view instead of relying
the proxy server setting workaround.

Thanks
Sundar


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p4191583.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by sunmoor007 <su...@gmail.com>.
Added the below method to AppModule.java

public LinkCreationListener buildLinkCreationListener(
			LinkCreationHub hub) {

		LinkCreationListener listener = new MyLinkCreationListenerImpl();
		hub.addListener(listener);
		return listener;
	} 


Created a sample impl class something like one below..

package test.abc

import org.apache.tapestry5.Link;
import org.apache.tapestry5.services.LinkCreationListener;

public class MyLinkCreationListenerImpl implements LinkCreationListener {

	public void createdComponentEventLink(Link arg0) {
		arg0.addParameter("test", String.valueOf(System.currentTimeMillis()));

	}

	public void createdPageRenderLink(Link arg0) {
		arg0.addParameter("test", String.valueOf(System.currentTimeMillis()));

	}

}

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3929002.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by Martin Strand <do...@gmail.com>.
On Fri, 18 Mar 2011 12:39:03 +0100, Thiago H. de Paula Figueiredo  
<th...@gmail.com> wrote:

> On Fri, 18 Mar 2011 01:25:43 -0300, sunmoor007 <su...@gmail.com>  
> wrote:
>
>> Added the below method to AppModule.java
>>
>> public LinkCreationListener buildLinkCreationListener(
>>                         LinkCreationHub hub) {
>
> Make the method static and try again please.

Builder methods do not need to be static.


Either way, this thread is based on a false premise:

> I believe the only way to prevent the proxy server caching links is to  
> have
> a dynamic parameter in url so that everytime proxy server identifies it  
> as a
> new request and hence it wont cache.

That is simply not true. Any working proxy server would never cache a  
response which has appropriate headers such as Cache-Control: no-cache or  
no-store.
If this really isn't working you should dig deeper and find out why, e.g.  
are you sure the headers were really added to the response?
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 18 Mar 2011 01:25:43 -0300, sunmoor007 <su...@gmail.com> wrote:

> Added the below method to AppModule.java
>
> public LinkCreationListener buildLinkCreationListener(
>                         LinkCreationHub hub) {

Make the method static and try again please.

>
>                 LinkCreationListener listener = new
> MyLinkCreationListenerImpl();
>                 hub.addListener(listener);
>                 return listener;
>         }
>
>
> Created a sample impl class something like one below..
>
> package test.abc
>
> import org.apache.tapestry5.Link;
> import org.apache.tapestry5.services.LinkCreationListener;
>
> public class MyLinkCreationListenerImpl implements LinkCreationListener {
>
>         public void createdComponentEventLink(Link arg0) {
>                 arg0.addParameter("test",
> String.valueOf(System.currentTimeMillis()));
>
>         }
>
>         public void createdPageRenderLink(Link arg0) {
>                 arg0.addParameter("test",
> String.valueOf(System.currentTimeMillis()));
>
>         }
>
> }
>
> I assumed the above code should be sufficient to provide link creation
> service as i have even kept the method name using the notation
> "build"+service name. Despite that i observed that url is not getting
> modified at all. Would be really helpful if you can provide some inputs  
> on
> this.
>
> --
> View this message in context:  
> http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3929745.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
Coordenador e professor da Especialização em Engenharia de Software com  
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by sunmoor007 <su...@gmail.com>.
Added the below method to AppModule.java 

public LinkCreationListener buildLinkCreationListener( 
                        LinkCreationHub hub) { 

                LinkCreationListener listener = new
MyLinkCreationListenerImpl(); 
                hub.addListener(listener); 
                return listener; 
        } 


Created a sample impl class something like one below.. 

package test.abc 

import org.apache.tapestry5.Link; 
import org.apache.tapestry5.services.LinkCreationListener; 

public class MyLinkCreationListenerImpl implements LinkCreationListener { 

        public void createdComponentEventLink(Link arg0) { 
                arg0.addParameter("test",
String.valueOf(System.currentTimeMillis())); 

        } 

        public void createdPageRenderLink(Link arg0) { 
                arg0.addParameter("test",
String.valueOf(System.currentTimeMillis())); 

        } 

} 

I assumed the above code should be sufficient to provide link creation
service as i have even kept the method name using the notation
"build"+service name. Despite that i observed that url is not getting 
modified at all. Would be really helpful if you can provide some inputs on
this.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3929745.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Something like this (not tested):

public static MyLinkCreationListener  
buildMyLinkCreationListener(LinkCreationHub hub) {
	MyLinkCreationLister listener = new MyLinkCreationListener();
	hub.addListener(listener);
	return listener;
}

On Wed, 16 Mar 2011 14:48:33 -0300, sunmoor007 <su...@gmail.com> wrote:

> Hi Rich
>
> Thanks. I understood the implementation of listener but i was looking at  
> a
> way to integrate it so that all URL's in app gets modified. I understand
> that in app module we can plugin any service. Assume i have a impl class
> implementing the listener interface, how will i integrate it into  
> existing
> application so that all URL's have a dynamic parameter, say system time  
> in
> milliseconds appended to the url.
>
> The reason am trying to add the system time is to ensure that everytime a
> dynamic value is appended to url and hence proxy server wont cache and  
> show
> me stale data which is currently happening.
>
> Thanks
> Sundar
>
> --
> View this message in context:  
> http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3790608.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
Coordenador e professor da Especialização em Engenharia de Software com  
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 17 Mar 2011 10:57:06 -0300, sunmoor007 <su...@gmail.com> wrote:

> I also got the option what Thiago has suggested. I have created a method
> call buildLinkListener which takes LinkCreationHub as argument and  
> returns a LinkCreationListener object. One thing still am clueless is  
> how to integrate this in app module so that this method gets invoked for  
> all URL creation.

I need to do nothing, as you already created the method and added your  
LinkCreationListener implementation to the LinkCreationHub.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by sunmoor007 <su...@gmail.com>.
Thanks Rich.

I also got the option what Thiago has suggested. I have created a method
call buildLinkListener which takes LinkCreationHub as argument and returns a
LinkCreationListener object. One thing still am clueless is how to integrate
this in app module so that this method gets invoked for all URL creation. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3880003.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by Rich M <ri...@moremagic.com>.
On 03/16/2011 01:48 PM, sunmoor007 wrote:
> Hi Rich
>
> Thanks. I understood the implementation of listener but i was looking at a
> way to integrate it so that all URL's in app gets modified. I understand
> that in app module we can plugin any service. Assume i have a impl class
> implementing the listener interface, how will i integrate it into existing
> application so that all URL's have a dynamic parameter, say system time in
> milliseconds appended to the url.
Referencing these lines from ClientPersistentFieldStorageImpl.java:

135 	public void updateLink(Link link)
136 	{
137 	refreshClientData();
138 	
139 	if (clientData != null) link.addParameter(PARAMETER_NAME, clientData);
140 	}


You can see that the Link object has an addParameter function. You 
should be able to use this to add the system time to the URL as a 
parameter, from my understanding. Since you understand the 
implementation of listener, then that should be pretty simple.

It seems the last challenge you are facing is how you should setup your 
implementation of the listener in the Module so it will be used on link 
creation. That is a little bit beyond my scope of knowledge here, so 
I'll defer that answer to someone else.

> The reason am trying to add the system time is to ensure that everytime a
> dynamic value is appended to url and hence proxy server wont cache and show
> me stale data which is currently happening.
>
> Thanks
> Sundar
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3790608.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by sunmoor007 <su...@gmail.com>.
Hi Rich

Thanks. I understood the implementation of listener but i was looking at a
way to integrate it so that all URL's in app gets modified. I understand
that in app module we can plugin any service. Assume i have a impl class
implementing the listener interface, how will i integrate it into existing
application so that all URL's have a dynamic parameter, say system time in
milliseconds appended to the url.

The reason am trying to add the system time is to ensure that everytime a
dynamic value is appended to url and hence proxy server wont cache and show
me stale data which is currently happening.

Thanks
Sundar 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3790608.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by Rich M <ri...@moremagic.com>.
The following is an internal Tapestry implementation of 
LinkCreationListener and a related class that the implementation makes 
use of. Maybe this can help you get on your way.


http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientPersistentFieldStrategy.java?view=markup

http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ClientPersistentFieldStorageImpl.java?view=markup

On 03/16/2011 10:26 AM, sunmoor007 wrote:
> Hi Thiago
>
> Thanks again for your response.
>
> Will definitely try using LinkCreationListener/LinkCreationHub . Is it
> something which needs to be integrated in AppModule. I am relatively very
> new to Tapestry. Would really appreciate if you can provide a sample
> implementation for LinkCreationListener.
>
> Thanks
> Sundar
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3782668.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>


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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by sunmoor007 <su...@gmail.com>.
Hi Thiago

Thanks again for your response. 

Will definitely try using LinkCreationListener/LinkCreationHub . Is it
something which needs to be integrated in AppModule. I am relatively very
new to Tapestry. Would really appreciate if you can provide a sample
implementation for LinkCreationListener. 

Thanks
Sundar

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3782668.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 15 Mar 2011 09:28:21 -0300, sunmoor007 <su...@gmail.com> wrote:

> Hi Thiago

Hi!

> Thanks for the response. I checked the blog but it talks only about  
> incoming url.

Tapestry has outgoing URL rewriting too, but it's just not documented yet.
Maybe for your scenario it's easier to create a LinkCreationListener and  
add it to the LinkCreationHub service.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by sunmoor007 <su...@gmail.com>.
Hi Thiago

Thanks for the response. I checked the blog but it talks only about incoming
url. What about the redirect url's. Do we have a control over it. I observed
that because of the redirect after post patten in tapestry, i see that for a
simple action request there are two requests to the server. The second one
is a redirect request. 

Will anyway look at the second option you have mentioned.

Thanks again for your input.

thanks
Sundar

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-cache-issue-when-accessed-via-proxy-tp3388994p3702496.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Tapestry 5 - cache issue when accessed via proxy

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 15 Mar 2011 04:27:28 -0300, sunmoor007 <su...@gmail.com> wrote:

> Hi All

Hi!

> we have checked the proxy logs and issue seems to be because of the  
> presence of proxy server. Proxy server caches the url. As we dont have  
> the search
> criteria in the url,

Why not? That's the best approach in most scenarios, avoids session use  
and prevents the caching issue.

> Is there a way in Tapestry to dynamically include a parameter in url.

Yes. See  
http://blog.tapestry5.de/index.php/2010/09/06/new-url-rewriting-api/. In  
your case, you just need to add the query parameter. Another option is to  
return this parameter in the passivate event (onPassivate).

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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