留言板

Liferay 6.x Portlet /Disabling web browser cache:SOLUTION

Joe Kosik,修改在11 年前。

Liferay 6.x Portlet /Disabling web browser cache:SOLUTION

New Member 发布: 1 加入日期: 12-9-22 最近的帖子

(note: I am sure the Liferay admins would find this one as no surprise)

For those JSF / Primefaces portlet developers (fellow J2EE programmers) out there...

Liferay 6.x Portlet Development / Disabling web browser cache: SOLUTION / WORKAROUND

To disable the web browser caching of your primefaces / JSF portlets in Liferay...
... the answers turns out to be one of configuration. However, this turns-off web browser caching for ALL portlets in a given Liferay 6.X portal.

1. Open up a file editor
2. Paste in the following content:
__________________________________________________________________________________

##
## Browser Cache
##

    #
    # Set this to true if you want the portal to force the browser cache to be
    # disabled. It will only disable the cache for the rendered HTML response
    # It will not have an impact on static content or other resources.
    #
    browser.cache.disabled=true

    #
    # Set this true if you want to disable the cache for authenticated users.
    # This property is not read when the property
    # "browser.cache.signed.in.disabled" is true. This is useful to ensure that
    # authenticated users cannot go to the sign in page by clicking on the back
    # button in their browsers.
    #
    browser.cache.signed.in.disabled=true

__________________________________________________________________________________
3. Save as: [portal-ext.properties]
4. With your Liferay 6.X Portal shutdown, copy the file:[portal-ext.properties] into the directory:[/alpha/beta/gamma/.../omega/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes]
5. Restart Liferay Server paying attention to the logs for any startup / configuration errors

6. To test / confirm, using Firefox with Firebug plugin, access any portlet page, and check your Firebug plugin:
6.1 tab:[Net] / sub-tab:[HTML]
6.2 expand out the GET URL
6.3 click on sub-sub-tab:[Headers]
6.4 subsection:[Response Headers] should look something like this:
-------------------------------------------------------------------

	Server	Apache-Coyote/1.1
	Set-Cookie	JSESSIONID=5DA1E6DCAB27D2BF4206D65FEC45CEC6; Path=/; HttpOnly GUEST_LANGUAGE_ID=en_US; Expires=Sun, 22-Sep-2013 00:50:10 GMT; Path=/
	Content-Encoding	gzip
	Expires	Thu, 01 Jan 1970 00:00:00 GMT
	Cache-Control	private, no-cache, no-store, must-revalidate
	Pragma	no-cache
	Liferay-Portal	Liferay Portal Community Edition 6.1.1 CE GA2 (Paton / Build 6101 / July 31, 2012)
	Content-Type	text/html;charset=UTF-8
	Transfer-Encoding	chunked
	Date	Sat, 22 Sep 2012 00:50:10 GMT

-------------------------------------------------------------------
6.5 pay attention to "Expires", "Cache-Control", and "Pragma"

-------------------------------------------------------------------------------------------------------
Primefaces (v3.3.1), Mojarra JSF API Implementation 2.1.3 (b02-FCS), Liferay 6.1 CE (Tomcat 7.0.27), Linux operation system

thumbnail
Mazhar Alam,修改在11 年前。

RE: Liferay 6.x Portlet /Disabling web browser cache:SOLUTION

Regular Member 帖子: 191 加入日期: 11-11-25 最近的帖子
It seems helpful...
thumbnail
Neil Griffin,修改在11 年前。

RE: Liferay 6.x Portlet /Disabling web browser cache:SOLUTION

Liferay Legend 帖子: 2655 加入日期: 05-7-27 最近的帖子
Hi Joe,

Thanks for the post. emoticon When you get a chance, could you comment here with a typical use-case that developer will run into with PrimeFaces portlets in which they would want to disable caching?

Neil
Jan Tošovský,修改在11 年前。

RE: Liferay 6.x Portlet /Disabling web browser cache:SOLUTION

Liferay Master 帖子: 566 加入日期: 10-7-22 最近的帖子
I need it for session scoped beans - when global settings change between two views and you return to the original page, it is still displaying cached/outdated values.
Imagine a composed page. There are common options (e.g. time range) on the right and body area in the midddle (e.g. montly report). When you click on the link in that report to get detailed version, you can change that time range there as well. If you do it, the detailed report is updated.
But when you click the back browser button, the montly report data isn't updated to the updated time range. Everything is fine when you refresh the page (F5).

Thanks for the proposed solution, but clearing the cache globally is not acceptable for me...

Jan
Michele Giacobazzi,修改在11 年前。

RE: Liferay 6.x Portlet /Disabling web browser cache:SOLUTION

Junior Member 帖子: 40 加入日期: 11-9-9 最近的帖子
I have the "inverse" problem. All request receive a "no-cache" response, but I'd like to cache static files.

How could I activate browser cache?

I'm running liferay 6.1.1 bundled with tomcat
thumbnail
Manuel Hoyos,修改在11 年前。

RE: Liferay 6.x Portlet /Disabling web browser cache:SOLUTION

Junior Member 帖子: 60 加入日期: 12-6-11 最近的帖子
Michele Giacobazzi:
I have the "inverse" problem. All request receive a "no-cache" response, but I'd like to cache static files.

How could I activate browser cache?

I'm running liferay 6.1.1 bundled with tomcat



I have a same problem. In the documents portlet not download with internet explorer

What's the problem?

Thanks
thumbnail
Juan Gonzalez P,修改在11 年前。

RE: Liferay 6.x Portlet /Disabling web browser cache:SOLUTION

Liferay Legend 帖子: 3089 加入日期: 08-10-28 最近的帖子
If you're using 6.1.1, probably your hitting this issue:

http://issues.liferay.com/browse/LPS-29645

You can download patched version here:

https://www.lcepatchers.org/downloads