The
cache scope and cache expiry time are configured by page, portlet, and
theme. WebSphere Portal combines
this information to produce a final cache scope and expiry time for each page
it serves.
Cache
Settings
- Pages level
<content-node
action="update" active="true"
content-parentref="Z6_xxx" domain="rel"
objectid="Z6_xxx" ordinal="100" type="label"
uniquename="com.vakasiva.cachetest">
<supported-markup
markup="html" update="set"/>
<localedata
locale="en">
<title>SivaCacheTest</title>
</localedata>
<parameter
name="com.ibm.portal.IgnoreAccessControlInCaches"
type="string"
update="set"><![CDATA[false]]></parameter>
<parameter
name="com.ibm.portal.feed.remote-cache-expiry"
type="string"
update="set"><![CDATA[86400]]></parameter>
<parameter name="com.ibm.portal.remote-cache-expiry"
type="string"
update="set"><![CDATA[86400]]></parameter>
<parameter name="com.ibm.portal.remote-cache-scope"
type="string"
update="set"><![CDATA[NON-SHARED]]></parameter>
Scope
Values are : SHARED/NON-SHARED
Expiry
values are : 0 (never), -1(always) , number (specific sec)
NOTE:
By
default, WebSphere® Portal does not permit shared caching for
authenticated pages. You can use the Properties portlet or the XML
configuration interface to override these default settings using
the com.ibm.portal.IgnoreAccessControlInCaches parameter, but in most
cases this is not recommended.
- Portlet level
- Portlet Definition
Possible
settings at portlet definition level are
remote-cache-scope
(SHARED/NON_SHARED)
EXPIRATION_CACHE
(-1(never))
remote-cache-dynamic
(true/false) :
NOTE:
The remote cache dynamic setting is an optimization to notify the container
whether a portlet window can publish remote cache information at render time.
In portlet.xml
<portlet-app
... id="com.sivavaka.test.portletapp.cachetest">
<portlet>
<portlet-name>Cache
Test</portlet-name>
<expiration-cache>0</expiration-cache>
<cache-scope>private</cache-scope>
In import-portlet.xml
<request
..>
<portal action="locate">
<web-app action="update"
active="true" domain="rel" objectid="Z1_xxx"
removable="true"
uid="com.sivavaka.portletapp.cachetest.webmod">
<url>file:///c:/tmp/CacheTest.war</url>
<context-root>/wps/PA_CacheTest</context-root>
<display-name>PA_CacheTest</display-name>
<servlet
action="update" active="true" domain="rel"
name="Cache Test" objectid="ZV_xx" remote-cache-dynamic="false"/>
<portlet-app
action="update" active="true" defaultlocale="en"
domain="rel" name="com.sivavaka.portletapp.cachetest"
objectid="Z2_xx" uid="com.sivavaka.portletapp.cachetest">
<role
actionset="User" update="set">
<mapping
subjectid="all authenticated portal users"
subjecttype="user_group" update="set"/>
</role>
</access-control>
<portlet
action="update" cache-expiration="0"
active="true" defaultlocale="en" domain="rel"
name="Report Links" objectid="Z3_xx"
provided="false" servletref="ZV_xx">
</portlet>
</portlet-app>
</web-app>
</portal>
</request>
Or
using the manage portlets
- Portlet Window (portlet instance level during rendering time)
String
paramExpiry = "3000";
String
paramScope = "SHARED";
renderResponse.setProperty(
"portlet.remote-cache-scope", paramScope );
renderResponse.setProperty(
RenderResponse.EXPIRATION_CACHE, paramExpiry )
//renderResponse.setProperty(
RenderResponse.CACHE_SCOPE, paramExpiry )
- Portlets Wide (Across all portlets)
You
can set the global settings in WP Navigator service provider
remote.cache.expiration
(values : Number)
remoteCacheInfo.response.header.vary
(values : List of HTTP header fields that can be put into the vary response
header)
- Theme level
You
can add following in theme import xml
<parameter
update="set" name="com.ibm.portal.remote-cache-scope"
type="string">SHARED</parameter>
<parameter
update="set" name="com.ibm.portal.remote-cache-expiry"
type="string">3000</parameter>
Cache
Scopes
The cache scope determines where the content is
cached.
There are
two types of caching:
- Shared cache across users :
A proxy server caches content and serves requests for the content.
Not good for customized content. The following default values exist for portlet
definitions and themes if nothing is provided:
Note: This type of
caching should be used only for pages that contain public content that is not
personalized.
- Remote cache scope is non-shared
- Remote cache expiry is 0 seconds
- Non-shared cache for a single user (Web browser cache):
The cache is typically located in each user's Web browser. Can be
used for personalized content also . But if the computer is shared among
multiple users, a user may see personalized content from other users if served
from the browser cache. To prevent this from happening, do not enable private
caching, even for personalize content.
Globabl
Settings (In WP Navigator service)
- public.session
- public.expires
- remote.cache.expiration
- remoteCacheInfo.response.header.vary
- public.cache-control
- private.cache-control
Calculating
how its cached
Multiple factors can
affect the cache scope and expiry time for a page. The remote-cache-scope and
remote-cache-expiration of a rendered page view is calculated as the minimum of
the following factors:
- Cache scope and expiry time specified for the page
- Cache scope and expiry time of the portlets on the page
- Cache scope and expiry time of the theme
- Global values as defined in the Navigator Service
NOTE: Ensure that the cache settings for all
portlets on the page are consistent with the cache settings for the page. For
example, if one portlet on a page is set to only be cached in a private browser
cache, then the entire page can only be cached in a private browser cache, and
performance is not optimal.
Reference:
No comments:
Post a Comment