포틀릿을 위한 캐싱 정책 구성
포틀릿을 위한 단편 캐싱은 사용자가 포틀릿 웹 애플리케이션 아카이브(WAR) 파일 안에서 또는 글로벌하게 cachespec.xml 파일에서 캐시 정책을 정의해야 합니다. 정의되고 특정 포틀릿에 적용할 수 있는 캐싱 정책이 없는 경우, 해당 포틀릿은 캐시되지 않습니다.
WebSphere® Application Server 캐싱 정책은 캐시 ID 및 개별 포틀릿의 특정 요구사항을 만족하는 무효화 규칙 정의를 위한 많은 유연성을 제공합니다. 사용자가 정의할 수 있는 캐싱 정책이 반드시 Java 포틀릿 스펙에 의해 정의되는 캐싱 동작을 준수하지는 않습니다. 다음 섹션은 해당 스펙을 준주하는 캐싱 정책을 정의하기 위해 cachespec.xml 파일의 기능을 이용할 수 있는 방법에 대한 몇 가지 권장사항을 제공합니다.
캐시 만기. 포틀릿은 portlet.xml 배치 디스크립터의 <expiration-cache> 요소에서 캐시 만기 시간을 정의합니다. 이 요소가 존재하지 않거나 0의 값을 갖는 경우 포틀릿은 캐시되지 않습니다. 포틀릿에 대한 캐시 만기 시간은 배치 디스크립터에서만 정의됩니다. cachespec.xml 파일에서 지정되는 모든 캐시 제한시간 값은 효력이 없습니다.
<component id="com.ibm.wsspi.portletcontainer.user_cache_scope" type="attribute"/>
이
속성은 다음 값을 갖습니다. - 공용 캐시 범위를 정의하는 포틀릿에서 값 public.
- 개인용 캐시 범위를 정의하는 포틀릿에서 현재 로그온 사용자 ID.
- 로그온된 사용자가 없는 경우 개인용 캐시 범위를 정의하는 포틀릿의 널(익명).
익명 액세스를 위한 포틀릿 컨텐츠를 캐시하려는 경우, 개인용 캐시 범위를 정의하는 포틀릿에서도 <required>false</required>를 캐시 키 컴포넌트에 추가하십시오. 이것은 모든 익명 브라우저 액세스가 동일한 캐시 컨텐츠를 검색할 것임을 암시합니다.
<component id="javax.portlet.lifecycle_phase" type="attribute">
<value>RENDER_PHASE</value>
</component>
이 캐시 키 컴포넌트만 렌더링
요청을 포틀릿에 캐시합니다. RESOURCE_PHASE를 추가하여 추가
자원 요청을 캐시하십시오. 많은 경우에 최상의 접근 방법은
자원 요청에 대해 별도의 <cache-id> 요소를
정의하는 것입니다. 자원 ID는 자원 요청에서 키 생성 캐싱을 위한
com.ibm.wsspi.portletcontainer.resource_id 요청 속성에서 사용 가능합니다. <component id="com.ibm.wsspi.portletcontainer.all_parameters" type="attribute">
<required>false</required>
</component>
특정 포틀릿에 대한 캐시 정책을 작성하고
포틀릿의 어떤 보기가 어떤 요청 매개변수에 의해 다루어지는지를 정확하게
아는 경우, 대개 포틀릿의 가장 중요한 보기만을 캐시하기 위해 캐시 키에서
특정 <parameter> 요소를 사용하는 것이 더 효율적입니다. 기타 캐시 키 컴포넌트. 사용자의 사용법 시나리오에 따라서, 리턴된 컨텐츠가 기타 정보(예: 포틀릿 모드 및 창 상태 또는 다중 언어 포털의 요청 로케일)에 의존하는 경우 캐시 키에 해당 정보를 포함해야 합니다. 서로 다른 마크업 유형을 지원하는 다중 디바이스 포털에서, 리턴된 컨텐츠 유형도 캐시 키의 일부여야 합니다. 포틀릿에 대한 컨텐츠 유형은 com.ibm.wsspi.portletcontainer.response_contenttype 요청 속성에서 사용 가능합니다.
캐시 무효화. Java 포틀릿 스펙은 포틀릿에 대한 조치 및 이벤트 요청이 모든 현재 캐시된 컨텐츠를 무효화해야 함을 선언합니다. 포틀릿 캐싱 정의는 대개 포틀릿의 다중 보기를 동시에 캐시하도록 허용합니다. 모두를 무효화하려면 cachespec.xml의 종속성 ID 메커니즘을 사용하십시오.
<dependency-id>action
<component id="" type="portletWindowId"/>
<component id="com.ibm.wsspi.portletcontainer.user_cache_scope" type="attribute"/>
</dependency-id>
<invalidation>action
<component id="" type="portletWindowId"/>
<component id="com.ibm.wsspi.portletcontainer.user_cache_scope" type="attribute"/>
<component id="javax.portlet.lifecycle_phase" type="attribute" ignore-value="true">
<value>ACTION_PHASE</value>
<value>EVENT_PHASE</value>
</component>
</invalidation>
Sample cachespec.xml file
<?xml version="1.0"?>
<!DOCTYPE cache SYSTEM "cachespec.dtd">
<cache>
<cache-entry>
<class>portlet</class>
<name>MyPortlet</name>
<property name="consume-subfragments">true</property>
<cache-id>
<component id="" type="portletWindowId"/>
<component id="com.ibm.wsspi.portletcontainer.user_cache_scope" type="attribute"/>
<component id="" type="portletWindowState">
<!-- minimized portlets are not cached -->
<not-value>minimized</not-value>
</component>
<component id="" type="portletMode"/>
<component id="" type="locale"/>
<component id="com.ibm.wsspi.portletcontainer.response_contenttype" type="attribute"/>
<component id="com.ibm.wsspi.portletcontainer.all_parameters" type="attribute">
<required>false</required>
</component>
<component id="javax.portlet.lifecycle_phase" type="attribute">
<value>RENDER_PHASE</value>
</component>
</cache-id>
<dependency-id>action
<component id="" type="portletWindowId"/>
<component id="com.ibm.wsspi.portletcontainer.user_cache_scope" type="attribute"/>
</dependency-id>
<invalidation>action
<component id="" type="portletWindowId"/>
<component id="com.ibm.wsspi.portletcontainer.user_cache_scope" type="attribute"/>
<component id="javax.portlet.lifecycle_phase" type="attribute" ignore-value="true">
<value>ACTION_PHASE</value>
<value>EVENT_PHASE </value>
</component>
</invalidation>
</cache-entry>
</cache>