May 10, 2020
Estimated Post Reading Time ~

AEM Dispatcher

Methods for Caching
The Dispatcher has two primary methods for updating the cached content when changes are made to the website.
  • Content Updates remove the pages that have changed, as well as files that are directly associated with them.
  • Auto-Invalidation automatically invalidates those parts of the cache that may be out of date after an update. i.e. it effectively flags relevant pages as being out of date, without deleting anything.
Content Updates
In a content update, one or more AEM documents change. AEM sends a syndication request to the Dispatcher, which updates the cache accordingly:
  1. It deletes the modified file(s) from the cache.
  2. It deletes all files that start with the same handle from the cache. For example, if the file /en/index.html is updated, all the files that start with /en/index. are deleted. This mechanism allows you to design cache-efficient sites, especially in regard to picture navigations.
  3. It touches the so-called statfile; this updates the timestamp of the statfile to indicate the date of the last change.
The following points should be noted:
  • Content Updates are typically used in conjunction with an authoring system which “knows” what must be replaced.
  • Files that are affected by a content update are removed, but not replaced immediately. The next time such a file is requested, the Dispatcher fetches the new file from the AEM instance and places it in the cache, thereby overwriting the old content.
  • Typically, automatically generated pictures that incorporate text from a page are stored in picture files starting with the same handle – thus ensuring that the association exists for deletion. For example, you may store the title text of the page mypage.html as the picture mypage.titlePicture.gif in the same folder. This way the picture is automatically deleted from the cache each time the page is updated, so you can be sure that the picture always reflects the current version of the page.
  • You may have several statfiles, for example one per language folder. If a page is updated, AEM looks for the next parent folder containing a statfile, and touches that file.
Auto-invalidation
Auto-invalidation automatically invalidates parts of the cache – without physically deleting any files. At every content update, the so-called statfile is touched, so its timestamp reflects the last content update.
The Dispatcher has a list of files that are subject to auto-invalidation. When a document from that list is requested, the Dispatcher compares the date of the cached document with the timestamp of the statfile:
  • if the cached document is newer, the Dispatcher returns it.
  • if it is older, the Dispatcher retrieves the current version from the AEM instance.
Again, certain points should be noted:
  • Auto invalidation is typically used when the inter-relations are complex e.g. for HTML pages. These pages contain links and navigation entries, so they usually have to be updated after a content update. If you have automatically generated PDF or picture files, you may choose to auto-invalidate those too.
  • Auto-invalidation does not involve any action by the dispatcher at update time, except for touching the statfile. However, touching the statfile automatically renders the cache content obsolete, without physically removing it from the cache.
Using a Dispatcher with an Author Server
if you are using AEM with Touch UI you should not cache author instance content. If caching was enabled for the author instance, you need to disable it and delete the contents of the cache directory. To disable caching, you should edit the author_dispatcher.any file and modify the /rule property of the /cache section as follows:
/rules
{
/0000
{ /type "deny" /glob "*"}
}


A Dispatcher can be used in front of an author instance to improve authoring performance. To configure an authoring Dispatcher, do the following:
  • Install a Dispatcher in a web server (this could be Apache, iPlanet, or IIS web server).
  • You may wish to test the newly installed Dispatcher against a working AEM publish instance, to ensure that a baseline correct install has been achieved.
  • Now make sure that the Dispatcher is able to connect via TCP/IP to your author instance.
  • Replace the Dispatcher’s sample dispatcher.any file with the author_dispatcher.any file provided below.
  • Open the author_dispatcher.any in a text editor and make the following changes:
  1. Change the /hostname and /port of the /renders section to point to your author instance.
  2. Change the /docroot of the /cache section to point to a cache directory. In case you are using AEM with Touch UI, see the warning above.
  3. Save the changes.
  • Delete all existing files in the /cache > /docroot directory which you configured above.
  • Restart the web server.
Dispatcher Configuration Files
By default the Dispatcher configuration is stored in the dispatcher.any text file, though you can change the name and location of this file during installation.
The configuration file contains a series of single-valued or multi-valued properties that control the behavior of Dispatcher:
  • Property names are prefixed with a forward slash (“/”).
  • Multi-valued properties enclose child items using braces (“{ }”).
An example configuration is structured as follows:
# name of the dispatcher
/name "internet-server"

# each farm configures a set off (loadbalanced) renders
/farms
{
# first farm entry (label is not important, just for your convenience)
/website
{
/clientheaders
{
# List of headers that are passed on
}
/virtualhosts
{
# List of URLs for this Web site
}
/sessionmanagement
{
# settings for user authentification
}
/renders
{
# List of AEM instances that render the documents
}
/filter
{
# List of filters
}
/vanity-urls
{
# List of vanity URLs
}
/cache
{
# Cache configuration
/rules
{
# List of cachable documents
}
/invalidate
{
# List of auto-invalidated documents
}
}
/statistics
{
/categories
{
# The document categories that are used for load balancing estimates
}
}
/stickyConnectionsFor "/myFolder"
/health_check
{
# Page gets contacted when an instance returns a 500
}
/retryDelay "1"
/numberOfRetries "5"
/unavailablePenalty "1"
/failover "1"
}
}


You can include other files that contribute to the configuration:
If your configuration file is large you can split it into several smaller files (that are easier to manage) then include these.
To include files that are generated automatically.
For example, to include the file myFarm.any in the /farms configuration use the following code:
/farms
{
$include "myFarm.any"
}


Use the asterisk (“*”) as a wildcard to specify a range of files to include.

Defining Farms – /farms
The /farms property defines one or more sets of Dispatcher behaviors, where each set is associated with different web sites or URLs. The /farms property can include a single farm or multiple farms:
  • Use a single farm when you want Dispatcher to handle all of your web pages or web sites in the same way.
  • Create multiple farms when different areas of your web site or different web sites require different Dispatcher behavior.
The /farms property is a top-level property in the configuration structure. To define a farm, add a child property to the /farms property. Use a property name that uniquely identifies the farm within the Dispatcher instance.

The /farmname property is multi-valued, and contains other properties that define Dispatcher behavior:
  • The URLs of the pages that the farm applies to.
  • One or more service URLs (typically of AEM publish instances) to use for rendering documents.
  • The statistics to use for load-balancing multiple document renderers.
  • Several other behaviors, such as which files to cache and where.
The value can have include any alphanumeric (a-z, 0-9) character. The following example shows the skeleton definition for two farms named /daycom and /docsdaycom:
#name of dispatcher
/name "day sites"
#farms section defines a list of farms or sites
/farms
{
/daycom
{
...
}
/docdaycom
{
...
}
}


If you use more than one render farm, the list is evaluated bottom-up. This is particularly relevant when defining Virtual Hosts for your websites.
Each farm property can contain the following child properties:
Property nameDescription
/homepageDefault homepage
(optional)(IIS only)
/clientheadersThe headers from the client HTTP request to pass through.
/virtualhostsThe virtual hosts for this farm.
/sessionmanagementSupport for session management and authentication.
/rendersThe servers that provide rendered pages (typically AEM publish instances).
/filterDefines the URLs to which Dispatcher enables access.
/vanity-urlsConfigures access to vanity URLs.
/propagateSyndPostSupport for the forwarding of syndication requests.
/cacheConfigures caching behavior.
/statisticsDefining statistic categories for load-balancing calculations.
/stickyConnectionsForThe folder that contains sticky documents.
/health_checkThe URL to use to determine server availability.
/retryDelayThe delay before retrying a failed connection.
/unavailablePenaltyPenalties that affect statistics for load-balancing calculations.
/failoverResend requests to different renders when the original request fails.

Specify a Default Page (IIS Only) – /homepage
Caution:
This parameter is IIS only and will not have any effect in the other web servers.

The optional /homepage parameter specifies the page that Dispatcher returns when a client requests an undeterminable page or file.
Typically this situation occurs when a user specifies an URL for which neither IIS or AEM provides an automatic redirection target. For example, if the AEM render instance is shut down after the content is cached, the content redirect URL is unavailable.
The /homepage section is located inside the /farms section, for example:
#name of dispatcher
/name "day sites"
#farms section defines a list of farms or sites
/farms
{
/daycom
{
/homepage "/index.html"
...
}
/docdaycom
{
...
}
}
Specifying the HTTP Headers to Pass Through – /clientheaders

The /clientheaders property defines a list of HTTP headers that Dispatcher passes from the client HTTP request to the renderer (AEM instance).
By default Dispatcher forwards the standard HTTP headers to the AEM instance. In some instances, you might want forward additional headers, or remove specific headers:
Add headers, such as custom headers, that your AEM instance expects in the HTTP request.
Remove headers, such as authentication headers, that are only relevant to the web server.

If you customize the set of headers to pass through, you must specify an exhaustive list of headers, including those that are normally included by default.
The following code is an example configuration for /clientheaders:
/clientheaders
{
"CSRF-Token"
"X-Forwarded-Proto"
"referer"
"user-agent"
"authorization"
"from"
"content-type"
"content-length"
"accept-charset"
"accept-encoding"
"accept-language"
"accept"
"host"
"if-match"
"if-none-match"
"if-range"
"if-unmodified-since"
"max-forwards"
"proxy-authorization"
"proxy-connection"
"range"
"cookie"
"cq-action"
"cq-handle"
"handle"
"action"
"cqstats"
"depth"
"translate"
"expires"
"date"
"dav"
"ms-author-via"
"if"
"lock-token"
"x-expected-entity-length"
"destination"
"PATH"
}

Identifying Virtual Hosts – /virtualhosts
The /virtualhosts property defines a list of all hostname/URI combinations that Dispatcher accepts for this farm. You can use the asterisk (“*”) character as a wildcard. Values for the /virtualhosts property use the following format:
[scheme]host[uri][*]
scheme: (Optional) Either http:// or https://.
host: The name or IP address of the host computer and the port number if necessary. (See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23)
uri: (Optional) The path to the resources.

The following example configuration handles requests for the .com and .ch domains of myCompany, and all domains of mySubDivision:
/virtualhosts
{
"www.myCompany.com"
"www.myCompany.ch"
"www.mySubDivison.*"
}

Resolving the Virtual Host
When Dispatcher receives an HTTP or HTTPS request, it finds the virtual host value that best-matches the host, uri, and scheme headers of the request. Dispatcher evaluates the values in the virtualhosts properties in the following order:
Dispatcher begins at the lowest farm and progresses upward in the dispatcher.any file.
For each farm, Dispatcher begins with the topmost value in the virtualhosts property and progresses down the list of values.
Dispatcher finds the best-matching virtual host value in the following manner:
The first-encountered virtual host that matches all three of the host, the scheme, and the uri of the request is used.
If no virtualhosts values has scheme and uri parts that both match the scheme and uri of the request, the first-encountered virtual host that matches the host of the request is used.
If no virtualhosts values have a host part that matches the host of the request, the topmost virtual host of the topmost farm is used.

Therefore, you should place your default virtual host at the top of the virtualhosts property in the topmost farm of your dispatcher.any file.

Enabling Secure Sessions – /sessionmanagement
/allowAuthorized must be set to “0” in the /cache section in order to enable this feature.

Create a secure session for access to the render farm so that users need to log in to access any page in the farm. After logging in, users can access all pages in the farm. See Creating a Closed User Group for information about using this feature with CUGs.
If sections of your website use different access requirements, you need to define multiple farms.

/sessionmanagement has several sub-parameters:

An example configuration looks as follows:
/sessionmanagement
{
/directory "/usr/local/apache/.sessions"
/encode "md5"
/header "HTTP:authorization"
/timeout "800"
}

Defining Page Renderers – /renders
The /renders property defines the URL to which Dispatcher sends requests to render a document. The following example /renders section identifies a single AEM instance for rendering:
/renders
{
/myRenderer
{
# hostname or IP of the renderer
/hostname "aem.myCompany.com"
# port of the renderer
/port "4503"
# connection timeout in milliseconds, "0" (default) waits indefinitely
/timeout "0"
}
}
The following example /renders section identifies an AEM instance that runs on the same computer as Dispatcher:
/renders
{
/myRenderer
{
/hostname "127.0.0.1"
/port "4503"
}
}
The following example /renders section distributes render requests equally among two AEM instances:
/renders
{
/myFirstRenderer
{
/hostname "aem.myCompany.com"
/port "4503"
}
/mySecondRenderer
{
/hostname "127.0.0.1"
/port "4503"
}
}


Configuring Access to Content – /filter
Use the /filter section to specify the HTTP requests that Dispatcher accepts. All other requests are sent back to the web server with a 404 error code (page not found). If no /filter section exists, all requests are accepted.
Note: Requests for the statfile are always rejected.

The /filter section consist of a series of rules that either deny or allow access to content according to patterns in the request-line part of the HTTP request. You should use a whiltelist strategy for your /filter section:
First, deny access to everything.
Allow access to content as needed.

Defining a Filter
Each item in the /filter section includes a type and a pattern that is matched with a specific element of the request line or the entire request line. Each filter can contain the following items:
Type: The /type indicates whether to allow or deny access for the requests that match the pattern. The value can be either allow or deny.
Element of the Request Line: Include /method, /url, /query, or /protocol and a pattern for filtering requests according to these specific parts of the request-line part of the HTTP request. Filtering on elements of the request line (rather than on the entire request line) is the preferred filter method.
glob Property: The /glob property is used to match with the entire request-line of the HTTP request.

Example Filter: Deny All

The following example filter section causes Dispatcher to deny requests for all files. You should deny access to all files and then allow access to specific areas.
/0001 { /glob "*" /type "deny" }
Requests to an explicitly denied area result in a 404 error code (page not found) being returned.

Example Filter: Deny Acess to Specific Areas

Filters also allow you to deny access to various elements for example ASP pages and sensitive areas within a publish instance. The following filter denies access to ASP pages:
/0002 { /type "deny" /url "*.asp" }

Example Filter: Enable POST Requests
The following example filter allows submitting form data by the POST method:
/filter {
/0001 { /glob "*" /type "deny" }
/0002 { /type "allow" /method "POST" /url "/content/[.]*.form.html" }
}

Example Filter: Allow Access to the Workflow Console
The following example shows a filter used to deny external access to the Workflow console:
/filter {
/0001 { /glob "*" /type "deny" }
/0002 { /type "allow" /url "/libs/cq/workflow/content/console*" }
}
When multiple filters patterns apply to a request, the last filter pattern that applies is effective.

Example filter: Using Regular Expressions
This filter enables extensions in non-public content directories using a regular expression, defined here between single quotes:
/005 { /type "allow" /extension '(css|gif|ico|js|png|swf|jpe?g)' }
Example filter: Filter Additional Elements of a Request URL

One of the enhancements introduced in dispatcher 4.2.0 is the ability to filter additional elements of the request URL. The new elements introduced are:
path
selectors
extension
suffix
These can be configured by adding the property of the same name to the filtering rule: /path, /selectors, /extensionand /suffix respectively.
Below is a rule example that blocks content grabbing from the /content path, using filters for path, selectors and extensions:
/006 {
/type "deny"
/path "/content"
/selectors '(feed|rss|pages|languages|blueprint|infinity|tidy)'
/extension '(json|xml|html)'
}


Enabling Access to Vanity URLs – /vanity_urls
Configure Dispatcher to enable access to vanity URLs that are configured for your CQ or AEM pages.
When access to vanity URLs is enabled, Dispatcher periodically calls a service that runs on the render instance to obtain a list of vanity URLs. Dispatcher stores this list in a local file. When a request for a page is denied due to a filter in the /filter section, Dispatcher consults the list of vanity URLs. If the denied URL is on the list, Dispatcher allows access to the vanity URL.
To enable access to vanity URLs, add a /vanity_urls section to the /farms section, similar to the following example:
/vanity_urls {
/url "/libs/granite/dispatcher/content/vanityUrls.html"
/file "/tmp/vanity_urls"
/delay 300
}

The /vanity_urls section contains the following properties:
/url: The path to the vanity URL service that runs on the render instance. The value of this property must be “/libs/granite/dispatcher/content/vanityUrls.html”.
/file: The path to the local file where Dispatcher stores the list of vanity URLs. Make sure that Dispatcher has write-access to this file.
/delay: (Seconds) The time between calls to the vanity URL service.

Forwarding Syndication Requests – /propagateSyndPost
Syndication requests are usually intended for Dispatcher only, so by default they are not sent to the renderer (for example, an AEM instance).
If necessary, set the /propagateSyndPost property to “1” to forward syndication requests to Dispatcher. If set, you must make sure that POST requests are not denied in the filter section.
Configuring the Dispatcher Cache – /cache
The /cache section controls how Dispatcher caches documents. Configure several sub-properties to implement your caching strategies:
/docroot
/statfile
/serveStaleOnError
/allowAuthorized
/rules
/statfileslevel
/invalidate
/invalidateHandler
/allowedClients
/ignoreUrlParams
/headers
/mode
An example cache section might look as follows:
/cache
{
/docroot "/opt/dispatcher/cache"
/statfile "/tmp/dispatcher-website.stat"
/allowAuthorized "0"
/rules
{
# List of files that are cached
}
/invalidate
{
# List of files that are auto-invalidated
}
}


Specifying the Cache Directory
The /docroot property identifies the directory where cached files are stored.
Note:
The value must be the exact same path as the document root of the web server so that Dispatcher and the web server handle the same files.
The web server is responsible for delivering the correct status code when the dispatcher cache file is used, that’s why it is important that it can find it as well.
If you use multiple farms, each farm must use a different document root.
Naming the Statfile
The /statfile property identifies the file to use as the statfile. Dispatcher uses this file to register the time of the most recent content update. The statfile can be any file on the web server.
The statfile has no content. When content is updated, Dispatcher updates the timestamp. The default statfile is named .stat and is stored in the docroot. Dispatcher blocks access to the statfile.
Note:
If /statfileslevel is configured, Dispatcher ignores the /statfile property and uses .stat as the name.

Caching When Authentication is Used
The /allowAuthorized property controls whether requests that contain any of the following authentication information are cached:
The authorization header.
A cookie named authorization.
A cookie named login-token.
By default, requests that include this authentication information are not cached because authentication is not performed when a cached document is returned to the client. This configuration prevents Dispatcher from serving cached documents to users who do not have the necessary rights.

However, if your requirements permit the caching of authenticated documents, set /allowAuthorized to one:
/allowAuthorized “1”
Note:
To enable session management (using the /sessionmanagement property), the /allowAuthorized property must be set to “0”.

Specifying the Documents to Cache
The /rules property controls which documents are cached according to the document path. Regardless of the /rules property, Dispatcher never caches a document in the following circumstances:
If the request URI contains a question mark (“?”).
This usually indicates a dynamic page, such as a search result that does not need to be cached.
The file extension is missing.
The web server needs the extension to determine the document type (the MIME-type).
The authentication header is set (this can be configured)
If the AEM instance responds with the following headers:
no-cache
no-store
must-revalidate

Each item in the /rules property includes a glob pattern and a type:
The glob pattern is used to match the path of the document.
The type indicates whether to cache the documents that match the glob pattern. The value can be either allow (to cache the document) or deny (to always render the document).
If you do not have dynamic pages (beyond those already excluded by the above rules), you can configure Dispatcher to cache everything. The rules section for this looks as follows:
/rules
{
/0000 { /glob "*" /type "allow" }
}

If there are some sections of your page that are dynamic (for example a news application) or within a closed user group, you can define exceptions:
Note:
Closed user groups must not be cached as user rights are not checked for cached pages.
/rules
{
/0000 { /glob "*" /type "allow" }
/0001 { /glob "/en/news/*" /type "deny" }
/0002 { /glob "*/private/*" /type "deny" }
}

Invalidating Files by Folder Level
Use the /statfileslevel property to selectively invalidate cached files according to their path:
Dispatcher creates .stat files in each folder from the docroot folder down to the level that you specify. The docroot folder is level 0.
When a file is updated, Dispatcher locates the folder on the file path that is at the statfileslevel, and invalidates all files below that folder.
Instead of invalidating all files, only the files on the same path as an updated file are cached.

For example, a multi-language website uses the structure /content/myWebsite/xx/topics, where xx represents the 2-letter identifier for each language. When /statfileslevel is three, (/statfileslevel = “3”), a .stat file is created in the following folders:
/content
/content/myWebsite
/content/myWebsite/xx (each language folder contains a .stat file)

When a file in the /content/myWebsite/fr/topics folder is activated, the .stat file below /content/myWebsite/fr is touched. All files in the fr folder are invalidated.
Note: If you specify a value for the /statfileslevel property, the /statfile property is ignored.
Automatically Invalidating Cached Files

The /invalidate property defines the documents that are automatically invalidated when content is updated.
With automatic invalidation, Dispatcher does not delete cached files after a content update, but checks their validity when they are next requested. Documents in the cache that are not auto-invalidated will remain in the cache until a content update explicitly deletes them.

Automatic invalidation is typically used for HTML pages. HTML pages often contain links to other pages, making it difficult to determine whether a content update affects a page. To make sure that all relevent pages are invalidated when content is updated, automatically invalidate all HTML pages. The following configuration invalidates all HTML pages:
/invalidate
{
/0000 { /glob "*" /type "deny" }
/0001 { /glob "*.html" /type "allow" }
}

This configuration causes the following activiy when the /content/geometrixx/en.html file is activated:
All the files with pattern en.* are removed from the /content/geometrixx/ folder.
The /content/geometrixx/en/jcr_content folder is removed.
All the other files that match the /invalidate configuration are not immediately deleted. These files are deleted when the next request occurs. In our example /content/geometrixx.html is not deleted, it will be deleted when /content/geometrixx.html is requested.

If you offer automatically generated PDF and ZIP files for download, you might have to automatically invalidate these as well. A configuration example this looks as follows:
/invalidate
{
/0000 { /glob "*" /type "deny" }
/0001 { /glob "*.html" /type "allow" }
/0002 { /glob "*.zip" /type "allow" }
/0003 { /glob "*.pdf" /type "allow" }
}

The AEM integration with Adobe Analytics delivers configuration data in an analytics.sitecatalyst.js file in your website. The example dispatcher.any file that is provided with Dispatcher includes the following invalidation rule for this file:
{
/glob "*/analytics.sitecatalyst.js" /type "allow"
}

Using custom invalidation scripts
The /invalidateHandler property allows you to define a script which is called for each invalidation request received by Dispatcher.
It is called with the following arguments:
Handle
The content path that is invalidated
Action
The replication Action (e.g. Activate, Deactivate)
Action Scope

The replication Action’s Scope (empty, unless a header of CQ-Action-Scope: ResourceOnly is sent, see Invalidating Cached Pages from AEM for details)
This can be used to cover a number of different use cases, such as invalidating other application specific caches, or to handle cases where the externalized URL of a page and its place in the docroot does not match the content path.

Below example script logs each invalidate request to a file.
/invalidateHandler "/opt/dispatcher/scripts/invalidate.sh"

sample invalidation handler script
#!/bin/bash
printf "%-15s: %s %s" $1 $2 $3>> /opt/dispatcher/logs/invalidate.log

Limiting the Clients That Can Flush the Cache
The /allowedClients property defines specific clients that are allowed to flush the cache. The globbing patterns are matched against the IP.
The following example:
denies access to any client
explicitly allows access to the localhost
/allowedClients
{
/0001 { /glob "*.*.*.*" /type "deny" }
/0002 { /glob "127.0.0.1" /type "allow" }
}

It is recommended that you define the /allowedClients.
If this is not done, any client can issue a call to clear the cache; if this is done repeatedly it can severely impact the site performance.
Ignoring URL Parameters
The ignoreUrlParams section defines which URL parameters are ignored when determining whether a page is cached or delivered from cache:
When a request URL contains parameters that are all ignored, the page is cached.
When a request URL contains one or more parameters that are not ignored, the page is not cached.
When a parameter is ignored for a page, the page is cached the first time that the page is requested. Subsequent requests for the page are served the cached page, regardless of the value of the parameter in the request.
To specify which parameters are ignored, add glob rules to the ignoreUrlParams property:
To ignore a parameter, create a glob property that allows the parameter.
To prevent the page to be cached, create a glob property that denies the parameter.
The following example causes Dispatcher to ignores the “q” parameter, so that request URLs that include the q parameter are cached:
/ignoreUrlParams
{
/0001 { /glob "*" /type "deny" }
/0002 { /glob "q" /type "allow" }
}

Using the example ignoreUrlParams value, the following HTTP request causes the page to be cached because the q parameter is ignored:
GET /mypage.html?q=5

e Designing Patterns for glob Properties.
Using the example ignoreUrlParams value, the following HTTP request causes the page to not be cached because the pparameter is not ignored:
GET /mypage.html?q=5&p=4

For information about glob properties, see Designing Patterns for glob Properties.
Caching HTTP Response Headers
Note:
This feature is avaiable with version 4.1.11 of the Dispatcher.
The /headers property allows you to define the HTTP header types that are going to be cached by the Dispatcher. On the first request to an uncached resource, all headers matching one of the configured values (see the configuration sample below) are stored in a separate file, next to the cache file. On subsequent requests to the cached resource, the stored headers are added to the response.
Presented below is a sample from the default configuration:
/cache {
...
/headers {
"Cache-Control"
"Content-Disposition"
"Content-Type"
"Expires"
"Last-Modified"
"X-Content-Type-Options"
"Last-Modified"
}
}

Note:Also, be aware that file globbing characters are not allowed. For more details, se
Dispatcher Cache File Permissions
The mode property specifies what file permissions are applied to new directories and files in the cache. This setting is restricted by the umask of the calling process. It is an octal number constructed from the sum of one or more of the following values:
  • 0400 Allow read by owner.
  • 0200 Allow write by owner.
  • 0100 Allow the owner to search in directories.
  • 0040 Allow read by group members.
  • 0020 Allow write by group members.
  • 0010 Allow group members to search in the directory.
  • 0004 Allow read by others.
  • 0002 Allow write by others.
  • 0001 Allow others to search in the directory.
The default value is 0755 which allows the owner to read, write or search and the group and others to read or search.

Configuring Time Based Cache Invalidation – /enableTTL
If set, the enableTTL property will evaluate the response headers from the backend, and if they contain a Cache-Controlmax-age or Expires date, an auxiliary, empty file next to the cache file is created, with modification time equal to the expiry date. When the cached file is requested past the modification time it is automatically re-requested from the backend.
You can enable the feature by adding this line to the dispatcher.any file:
/enableTTL "1"

Note:
This feature is avaiable with version 4.1.11 of the Dispatcher.

Configuring Load Balancing – /statistics
The /statistics section defines categories of files for which Dispatcher scores the responsiveness of each render. Dispatcher uses the scores to determine which render to send a request.
Each category that you create defines a glob pattern. Dispatcher compares the URI of the requested content to these patterns to determine the category of the requested content:
The order of the categories determines the order in which they are compared to the URI.
The first category pattern that matches the URI is the category of the file. No more category patterns are evaluated.
Dispatcher supports a maximum of 8 statistics categories. If you define more than 8 categories, only the first 8 are used.

Render Selection
Each time Dispatcher requires a rendered page, it uses the following algorithm to select the render:
If the request contains the render name in a renderid cookie, Dispatcher uses that render.
If the request includes no renderid cookie, Dispatcher compares the render statistics:
Dispatcher determines the cateogry of the request URI.
Dispatcher determines which render has the lowest response score for that category, and selects that render.

If no render is selected yet, use the first render in the list.
The score for a render’s category is based on previous response times, as well as previous failed and successful connections that Dispatcher attempts. For each attempt, the score for the category of the requested URI is updated.

Note:
If you do not use load balancing, you can omit this section.Defining Statistics Categorie
Define a category for each type of document for which you want to keep statistics for render selection. The /statistics section contains a /categories section. To define a category, add a line below the /categories section that has the following format:
/name { /glob “pattern“}

The category name must be unique to the farm. The pattern is described in the Designing Patterns for glob Properties section.

To determine the category of a URI, Dispatcher compares the URI with each category pattern until a match is found. Dispatcher begins with the first category in the list and continues in order. Therefore, place categories with more specific patterns first

For example, Dispatcher the default dispatcher.any file defines an HTML category and an others category. The HTML category is more specific and so it appears first:
/statistics
{
/categories
{
/html { /glob "*.html" }
/others { /glob "*" }
}
}


The following example also includes a category for search pages:
/statistics
{
/categories
{
/search { /glob "*search.html" }
/html { /glob "*.html" }
/others { /glob "*" }
}
}

Reflecting Server Unavailability in Dispatcher Statistics
The /unavailablePenalty property sets the time (in tenths of a second) that is applied to the render statistics when a connection to the render fails. Dispatcher adds the time to the statistics category that matches the requested URI.

For example, the penalty is applied when the TCP/IP connection to the designated hostname/port cannot be established, either because AEM is not running (and not listening) or because of a network-related problem.

The /unavailablePenalty property is a direct child of the /farm section (a sibling of the /statistics section).
If no /unavailablePenalty property exists, a value of “1” is used.
/unavailablePenalty "1"

Identifying a Sticky Connection Folder – /stickyConnectionsFor

The /stickyConnectionsFor property defines one folder that contains sticky documents; this will be accessed using the URL. Dispatcher sends all requests, from a single user, that are in this folder to the same render instance. Sticky connections ensure that session data is present and consistent for all documents. This mechanism uses the renderid cookie.
The following example defines a sticky connection to the /products folder:
/stickyConnectionsFor "/products"

When a page is composed of conent from several content nodes, include the /paths property that lists the paths to the content. For example, a page contains content from /content/image, /content/video, and /var/files/pdfs. The following configuration enables sticky connections for all content on the page:

/stickyConnections {
/paths {
"/content/image"
"/content/video"
"/var/files/pdfs"
}
}

Handling Render Connection Errors
Configure Dispatcher behavior when the render server returns a 500 error, or is unavailable.

Specifying a Health Check Page
Use the /health_check property to specify a URL that is checked when a 500 status code occurs. If this page also returns a 500 status code the instance is considered to be unavailable and a configurable time penalty (/unavailablePenalty) is applied to the render before retrying.

/health_check
{
# Page gets contacted when an instance returns a 500
/url "/health_check.html"
}

Specifying the Page Retry Delay
The /retryDelay property sets the time (in seconds) that Dispatcher waits between rounds of connection attempts with the farm renders. For each round, the maximum number of times Dispatcher attempts a connection to a render is the number of renders in the farm.
Dispatcher uses a value of “1” if /retryDelay is not explicitly defined. The default value is appropriate in most cases.
/retryDelay "1"

Configuring the Number of Retries
The /numberOfRetries property sets the maximum number of rounds of connection attempts that Dispatcher performs with the renders. If Dispatcher cannot successfully connect to a render after this number of retries, Dispatcher returns a failed response.
For each round, the maximum number of times Dispatcher attempts a connection to a render is the number of renders in the farm. Therefore, the maximum number of times that Dispatcher attempts a connection is (/numberOfRetries) x (the number of renders).
“5” is the default value used if not explicitly defined.
/numberOfRetries "5"

Using the Failover Mechanism
Enable the failover mechanism on your Dispatcher farm to resend requests to different renders when the original request fails. When failover is enabled, Dispatcher has the following behavior:
  • When a request to a render returns HTTP status 503 (UNAVAILABLE), Dispatcher sends the request to a different render.
  • When a request to a render returns HTTP status 50x (other than 503), Dispatcher sends a request for the page that is configured for the health_check property.
    • If the health check returns 500 (INTERNAL_SERVER_ERROR), Dispatcher sends the original request to a different render.
    • If the health check returns HTTP status 200, Dispatcher returns the initial HTTP 500 error to the client.
To enable failover, add the following line to the farm (or website):

/failover "1"

Note:
To retry HTTP requests that contain a body, Dispatcher sends a Expect: 100-continue request header to the render before spooling the actual contents. CQ 5.5 with CQSE then immediately answers with either 100 (CONTINUE) or an error code. Other servlet containers should support this as well.Ignoring Interruption Errors – /ignoreEINTR

Caution:
This option is not usually needed. You only need to use this when you see the following log messages:
Error while reading response: Interrupted system cal
Any file system oriented system call can be interrupted EINTR if the object of the system call is located on a remote system accessed via NFS. Whether these system calls can time out or be interrupted is based on how the underlying file system was mounted on the local machine.

Use the /ignoreEINTR parameter if your instance has such a configuration and the log contains the following message:
Error while reading response: Interrupted system call
Internally, Dispatcher reads the response from the remote server (i.e. AEM) using a loop that can be represented as:
while (response not finished) {
read more data
}
 
Such messages can be generated when the EINTR occurs in the “read more data” section and are caused by the reception of a signal before any data was received.
To ignore such interrupts you can add the following parameter to dispatcher.any (before /farms):
/ignoreEINTR “1”
 
Setting /ignoreEINTR to “1” causes Dispatcher to continue to attempt to read data until the complete response is read. The default value is 0 and deactivates the option.


By aem4beginner

No comments:

Post a Comment

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