Thursday, September 15, 2011

How to set up dynamic flushing based on path in CQ

Problem: Currently when you activate a page all the pages get invalided (Based on entry in /invalidate section in dispatcher.any) If you have very flat site structure, this could be a performance hit to the publish server. For example if you have site structure like /content/en , /content/es , /content/dam and you want that activating under /content/dam should not invalidate all the pages under /content/en or /content/es. In OOTB setting this is not possible to achieve. As for above case you need to set stat file level as 1.

Workaround: Thank fully there is workaround to above problem. Work around assume that you are using apache as web server. You need to do something similar in IIS which unfortunately I don't know. Workaround also assume that farm selection in dispatcher is based on HOST header, which is correct in current dispatcher release.

Approach: Since stat file level or invalidation can be per farm, We are going to create to create a separate farm to serve dam content and for DAM invalidation. We make sure that activation request and content request to DAM get FWD to new farm. For that we will use mod_env, mod_setenvif and mod_headers modules of apache.
Step 1: Add new host name to all the request for /content/dam (For our example). To do that add following entry under section of httpd.conf

RequestHeader set Host ""

#This make sure that flush request to DAM goes to DAM farm

SetEnv hostnameforfarm localhost
SetEnvIfNoCase CQ-Path ^/content/dam/
RequestHeader set Host %{hostnameforfarm}e

Step2 Create a new farm in dispatcher.any to handle all the DAM request and set invalidation to all html to false there. So your new dispatcher.any will look like this,
# name of the dispatcher
/name ""

# each farm configures a set off (loadbalanced) renders
# first farm entry (label is not important, just for you convenience)
.... all entry
# second farm entry (label is not important, just for you convenience)

-- All headers

# hostname globbing for farm selection (virtual domain addressing)


---Everything else and then

/glob "*.html"
/type "deny"


Now all the invalidation request to DAM will go to another farm, That will not invalidate any html pages.

You can customize above to have stat file at different level for second farm. That way you will not invalidate global stat file.

Note: You have to make sure that in your dispatcher flush you add CQ-Path header for this to work

Thanks Andrew Khoury from Adobe for this information.

No comments:

Post a Comment