Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
camille vienot
problems removing portlet cache for guest user
January 14, 2009 3:32 PM
Answer

camille vienot

Rank: New Member

Posts: 15

Join Date: October 10, 2008

Recent Posts

Hello community,
i have a problem with entirely removing the cache for my portlet. Indeed, my java code in the servlet, compiled from my view.jsp, is only re-executed when the user is logged in. In other word when the guest is not logged in, the portlet display the resulting html code from the first request done on the servlet.
Did anyone come accross this problem?
Thanks for your help,
Camille
camille vienot
RE: problems removing portlet cache for guest user
January 15, 2009 11:32 AM
Answer

camille vienot

Rank: New Member

Posts: 15

Join Date: October 10, 2008

Recent Posts

For example, if you deploy the simple portlet containing a single view.jsp:

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<portlet:defineObjects />
<%=java.lang.Math.random() %>


and add it on the home page, it should generate a random number each time the page is loaded. It works (the number is re-generated) when user is logged. But when the user is not logged, the number is always the same. I really dont get it.
thanks for reading,
Camille
camille vienot
RE: problems removing portlet cache for guest user
January 15, 2009 2:04 PM
Answer

camille vienot

Rank: New Member

Posts: 15

Join Date: October 10, 2008

Recent Posts

The problem is the same with a Journal Content portlet using a velocity template. The portlet content is cached when the user is not loged in and becomes dynamic when guest logs in.
Ahmad M. Arrabi
RE: problems removing portlet cache for guest user
February 23, 2009 4:47 AM
Answer

Ahmad M. Arrabi

Rank: New Member

Posts: 1

Join Date: February 23, 2009

Recent Posts

So, how we can solve problem? any ideas?
thank you
1
David Tildesley
RE: problems removing portlet cache for guest user
August 24, 2009 3:50 AM
Answer

David Tildesley

Rank: Junior Member

Posts: 34

Join Date: August 3, 2008

Recent Posts

camille vienot:
Hello community,
i have a problem with entirely removing the cache for my portlet. Indeed, my java code in the servlet, compiled from my view.jsp, is only re-executed when the user is logged in. In other word when the guest is not logged in, the portlet display the resulting html code from the first request done on the servlet.
Did anyone come accross this problem?
Thanks for your help,
Camille


Yes, I have got exactly this problem. I am using 5.2.3 and this problem is very disturbing. Did you find a solution?
Shawn G
RE: problems removing portlet cache for guest user
September 2, 2009 10:59 AM
Answer

Shawn G

Rank: New Member

Posts: 20

Join Date: August 28, 2009

Recent Posts

I am seeing this exact same issue, fortunately from this thread I'm glad to see it's not limited to me.

I am using a velocity template with Expando web content (although I don't think Expando has anything to do with it). I have the Cacheable option turned off. The only way I can get the content to refresh for the Guest user is to restart the server application, which obviously isn't a solution.
Shawn G
RE: problems removing portlet cache for guest user
September 3, 2009 12:03 PM
Answer

Shawn G

Rank: New Member

Posts: 20

Join Date: August 28, 2009

Recent Posts

I believe I have a workaround for this.

First of all, after reading a lot about portlet caches over the past two days, I believe this behavior is by design and most of the time is actually what you want for performance reasons. In most cases, the Web Content Display (aka Journal) portlet *should* be cached, and in fact I found several forum posts that indicate peformance significantly degrades if it is not.

I also learned that the <expiration-cache> settings found in portlet-custom.xml seem to be ignored completely by Guest users. Changing it does work for logged on users, but in my case logged on users aren't the problem.

There is a setting in liferay-portlet.xml called <layout-cacheable>. This setting determines whether a portlet is cacheable or not, and in the case of the Web Content Display it is set to true. Hence why this portlet caches. If you set it to false (and restart the server), all Web Content Display portlets will no longer cache for guest users.

However, this is a drastic solution since it appears to affect all Web Content Display portlets within Liferay. Most of the time I want the performance boost from the cache, so what I really need is a solution that only overrides the default cache setting for that specific instance of the portlet.

Enter the Nested Portlets application. By adding a Nested Portlets portlet to your page, turning off its borders, then dropping the Web Content Display inside it, the Web Content Display will no longer cache. The reason for this is because the Nested Portlets application is NOT layout-cacheable by default, and Liferay will disable cache of EVERY portlet on a page if ANY of them are not layout-cacheable.

I tested this both with my primary scenario as well as creating a new page with the same web content on it but no Nested Portlets. The page containing the Nested Portlets did not cache for the Guest user, while the new page still cached as expected.

In a perfect world, there would be a portlet checkbox along the lines of "override default settings", but this seems to work well enough.
David Tildesley
RE: problems removing portlet cache for guest user
September 20, 2009 4:16 AM
Answer

David Tildesley

Rank: Junior Member

Posts: 34

Join Date: August 3, 2008

Recent Posts

Shawn Gerlock:
I believe I have a workaround for this.

First of all, after reading a lot about portlet caches over the past two days, I believe this behavior is by design and most of the time is actually what you want for performance reasons. In most cases, the Web Content Display (aka Journal) portlet *should* be cached, and in fact I found several forum posts that indicate peformance significantly degrades if it is not.

I also learned that the <expiration-cache> settings found in portlet-custom.xml seem to be ignored completely by Guest users. Changing it does work for logged on users, but in my case logged on users aren't the problem.

There is a setting in liferay-portlet.xml called <layout-cacheable>. This setting determines whether a portlet is cacheable or not, and in the case of the Web Content Display it is set to true. Hence why this portlet caches. If you set it to false (and restart the server), all Web Content Display portlets will no longer cache for guest users.

However, this is a drastic solution since it appears to affect all Web Content Display portlets within Liferay. Most of the time I want the performance boost from the cache, so what I really need is a solution that only overrides the default cache setting for that specific instance of the portlet.

Enter the Nested Portlets application. By adding a Nested Portlets portlet to your page, turning off its borders, then dropping the Web Content Display inside it, the Web Content Display will no longer cache. The reason for this is because the Nested Portlets application is NOT layout-cacheable by default, and Liferay will disable cache of EVERY portlet on a page if ANY of them are not layout-cacheable.

I tested this both with my primary scenario as well as creating a new page with the same web content on it but no Nested Portlets. The page containing the Nested Portlets did not cache for the Guest user, while the new page still cached as expected.

In a perfect world, there would be a portlet checkbox along the lines of "override default settings", but this seems to work well enough.


I think the problem is actually worse than stated. I have a VM guest machine with XP and IE6 for the purpose of browser capability testing. I never use it to actually login to the portal but I do use it for guest only viewing. It is displaying content (from web content display portlet) which is several weeks old. I have tried everything on the server to try and get it to display the current content including clear caches on the server (via server administration), bounce the server, clear the browser cache (several times), remove the web content display portlet from the page and put a new one back on and show the same article, change the article by increasing the version number (and approve it) and remove the previous version. None of this works! I am completely losing confidence in LIferay 5.2.3 in it's capacity as a web content management server - how can I trust it to display current content to guests?
Shawn G
RE: problems removing portlet cache for guest user
September 21, 2009 8:16 AM
Answer

Shawn G

Rank: New Member

Posts: 20

Join Date: August 28, 2009

Recent Posts

I may be wrong, but that doesn't sound like the same cache problem I was experiencing. Even when I was struggling with the cache, restarting Liferay or clearing the cache from the control panel always worked. In fact, if I let it sit overnight it would clear on its own by the next morning (so there is some sort of cache timer for layout-cacheable portlets, I just don't know what it is).

Maybe you have a different issue (local browser cache, for example?) going on. A good thing to try is to use a few browsers and compare the results.