April 1, 2020
Estimated Post Reading Time ~

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 an entry in /invalidate section in dispatcher.any) If you have a 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 the OOTB setting, this is not possible to achieve. As for the above case you need to set stat file level as 1.

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

Approach: Since stat file-level or invalidation can be per farm, We are going to create a separate farm to serve dam content and for DAM invalidation. We make sure that activation requests and content requests to DAM get FWD to a new farm. For that, we will use mod_env, mod_setenvif and mod_headers modules of apache.

Step 1: Add a new hostname to all the requests for /content/dam (For our example). To do that add following entry under the section of httpd.conf

RequestHeader set Host "localhost.dam.com"
#This makes sure that flush request to DAM goes to DAM farm

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

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

# each farm configures a set off (loadbalanced) renders
/farms
{
# first farm entry (label is not important, just for you convenience)
/restofsite
{
.... all entry
}
# second farm entry (label is not important, just for you convenience)
/dam
{
/clientheaders
{

-- All headers
}

# hostname globbing for farm selection (virtual domain addressing)
/virtualhosts
{

"localhost.dam.com"
}

---Everything else and then

/invalidate
{
/0000
{
/glob "*.html"
/type "deny"
}

}


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

You can customize the above to have stat file at a different levels for the 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




By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.