Connect Tags (Enable Caching for individual Components in WCM )

Custom caching can be applied to Web Content Management Components by using connect tags to cache individual components referenced within presentation templates. This is done by replacing a component reference in a presentation template with a connect tag. This enables you to apply custom caching strategies to Web Content Management components to override your server's default caching strategy. You can also use this method to disable the Caching of Web Content Management components.

When first time presentation template is rendered, the component will be added to the cache. The next time the presentation template is rendered, the component will be displayed from the cache instead of being rendered afresh by the Web Content Management application. Not until it is expired from the cache will the component be rendered again by the Web Content Management application. For this reason, only components that do not require to be freshly rendered every time a page is accessed should be cached.


Connect tags are used to reference Web content components and apply customized caching to the components.

Steps
1. Enable connect tags
2. Enable process connect tags in presentation templtae
3. write the following tag


Step 1: To enable connect tags, you will need to do the following:

Open the WCMConfigService.properties file in an editor
was_profile_root/PortalServer/wcm/shared/app/config/wcmservices/


Configure "connect.businesslogic" to process either unknown hosts, or a selected host:

connect.businesslogic.hosts.[HOST]=true
connect.businesslogic.processunknownhosts=false

Step 2: Connect tags must be selected in presentation template form for connect tags to be processed.

The first time the presentation template is rendered, the element will be added to the cache. The next time the presentation template is rendered, the element will be displayed from the cache instead of being rendered afresh by the Web Content Management application.

Only elements that do not require to be freshly rendered every time a page is accessed should be cached.

Step 3:

<connectMOD="ComponentRenderer" SRV="cmpnt" PATH="/Site/SiteArea/Content" SOURCE="library" CMPNTNAME="TestNav" CONTENTCACHE="site" EXPIRES="REL 9000s"> </connect>

Parameter Details

MOD="ComponentRenderer"
This references the Web Content Management Render Module.

SRV="cmpnt"
The Service for this Module is "cmpnt".

PATH="/Site/SiteArea/Content"
This sets the context for the element.
The "sitepath" and "name" placeholders can be used instead of "PATH=" when caching menus or navigators:
<placeholder tag="sitepath"/>/<placeholder tag="name"/>

SOURCE="library"
Source is either "content", "site", "sitearea"
or "library". In this example it is "library" because the element
we are caching comes from a component.

CMPNTNAME="TestNav"
This is the name of the element to be cached.

CONTENTCACHE="site"
This is either "site or "session".

EXPIRES="REL 9000s"
The time the component will expire from the
cache is set here.



Note:
We can also use this method to disable caching. In this example the property CONTENTCACHE="none" is used to disable caching of this element.

<connect MOD="ComponentRenderer" SRV="cmpnt" PATH="/Site/SiteArea/Content" SOURCE ="library" CMPNTNAME="TestNav" CONTENTCACHE="none" > </connect>


Best Practices:
a). If you are caching a component that is used in more than one presentation template, it is best practice to save the connect tag as a HTML component and then reference that component in each presentation template.

b). If you have a set of cached components that use the same "Expires" setting, then it is best practice to save the "Expires=" parameter as a HTML component and then reference that component in each connect tag used to cache components.

If you then need to change the cached component tags, you only need to change it in the HTML component rather than in multiple presentation templates


No comments:

Post a Comment