Best Practices for a Dispatcher-Infused AEM Website


The AEM Dispatcher acts as a caching and load balancing mechanism, orchestrating the distribution of content to end users while enhancing performance and security. However, configuring the AEM Dispatcher optimally requires a deep understanding of best practices that align with your organization’s needs.

Whether you’re looking to improve page load times, enhance security, or simply ensure a seamless digital experience, these best practices will serve as your guide to harnessing the full potential of the AEM Dispatcher.

Structure as per Adobe Managed Services Dispatcher manual

Implementing the guidelines provided in the Adobe Experience Manager (AEM) documentation for structuring Dispatcher configurations (link: https://experienceleague.adobe.com/docs/experience-manager-learn/ams/dispatcher/overview.html?lang=en) is essential for efficiently managing and maintaining your AEM Dispatcher setup. Following these guidelines ensures a well-organized and scalable configuration, making it easier to manage different aspects of caching, load balancing, security, and performance. This practice results in a more reliable, maintainable, and adaptable Dispatcher setup tailored to your AEM application’s needs.

Crafting dispatcher filter rules for clarity and effectiveness:

  • Keep configs simple: If you can’t understand a configuration easily, it’s likely not a good setup.
  • Implement an ALLOWLIST approach for publish:
    • Begin by denying all URLs by default
    • then explicitly allow necessary URLs.
    • Deny insecure patterns (e.g., /crx/de, /lib, infinity) and opt for broad denials and specific allowances.

Sample Code for ALLOWLIST Approach:

/filter
{
    /0001 { /type "deny" /url "*" }       # Deny all URLs by default
    /0002 { /type "allow" /url "/content/test-site/us/en*" }     # Allow necessary content URLs
    /0003 { /type "deny" /url "/crx/*" }          # Deny CRX URLs
    /0004 { /type "deny" /url "/libs/*" }         # Deny libs URLs
    /0005 { /type "deny" /url "*infinity*" }     # Deny infinity pattern URLs
}

Use Descriptive Rule Names:

  • Avoid numeric rule names (/001, /002, etc.) to prevent clashes and enhance readability in logfiles to debug which rule blocked the request
  • Opt for descriptive names, promoting better organization and comprehension. Example (/allow-productdetails)

Specific Allow Approach:

  • When using an allow list, include all attributes like path, selectors, extension, and suffix.
  • Try to use the same order in each rule to make it readable

For more details refer to link. Section: “Filter configurations”

Parameter Handling using /ignoreUrlParams:

  • Use the /ignoreUrlParams section to manage URL parameters that bypass the dispatcher cache.
  • Example:
   /ignoreUrlParams
   {
       /0001 { /glob "nocache" /type "deny" }
       /0002 { /glob "*" /type "allow" }
   }

Here, the parameter “nocache” is denied cache, while all other parameters are allowed.

No Caching with Author:

Configure the dispatcher to avoid caching when used with the Author instance. Configuring “No Caching with Author” in the AEM Dispatcher prevents caching when interacting with the Author instance, ensuring real-time content updates during the authoring process. This is vital to maintain accurate previews and prevent stale content from being served to authors. Follow the link for detailed instructions on setting up this essential configuration. Link: https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/dispatcher.html?lang=en#using-a-dispatcher-with-an-author-server

Distinct files for Cache and Filter Rules for both author and publish instances:

Set up distinct cache and filter rules for the dispatcher when used with the Author and Publish instances. This ensures optimized performance and authoring experiences. This approach prevents caching-related conflicts in the authoring environment and maintains efficient caching for the public-facing content. By tailoring rules, you balance efficient caching and real-time authoring needs effectively.

For details refer to link. Sections:

  • Embrace the Allow-List and Allow Specific Approach for AEM publish
  • Embrace the Deny Specific Approach for AEM author

Optimize your dispatcher configuration by splitting it into modular files

This approach proves especially valuable when managing intricate dispatcher setups that serve multiple domains or encompass various scenarios. By segmenting configuration files, you enhance clarity, facilitate updates, and tailor settings for specific use cases, ensuring a more organized and efficient AEM Dispatcher environment.

Request Headers and Cookies:

  • Consider configuring the dispatcher to take into account specific request headers or cookies when determining cacheability.
  • Example: Use a custom request header like “X-Cache-Control” to provide cache directives that override default cache behavior for specific requests.

Content Invalidation:

  • Implement a strategy for content invalidation to ensure that cached content is refreshed when changes are made to the AEM repository.
  • Set up cache invalidation rules that are granular, targeting only the specific resources or sub-trees that have changed or are impacted.

For details refer to following links:

Gzip Compression:

To enhance page load times and minimize data transmission size, it’s essential to enable Gzip compression at the AEM Dispatcher level. In Apache Web Server, mod_deflate could be used.

Here are the steps to optimize Gzip compression:

  1. Apply GZip compression to responses for all file types that are not already pre-compressed.
  2. Ensure that this compression is configured at the dispatcher level to effectively reduce the volume of data sent to the Content Delivery Network (CDN). CDNs often charge based on the amount of data transferred, so compressing responses can lead to cost savings.
  3. When enabling GZip compression on the Dispatcher level in Apache, employ “mod_deflate.” However, be mindful of how “mod_deflate” utilizes the “Vary” header, as it can potentially lead to CDNs and browsers bypassing caching entirely.
    • As a common guideline, it’s advisable to refrain from incorporating the “Vary” header except in the case of “Vary: Accept-Encoding,” which should only be employed when the response is gzip compressed. In essence, if you require alterations in the response output, consider using a distinct URL.
    • For instance, if you possess distinct versions of HTML for mobile and desktop users, it’s better to employ separate URLs. This approach enhances the efficiency of caching for both CDNs and web browsers.
  4. For Microsoft IIS, utilize Dynamic Compression to achieve Gzip compression.
  5. Be cautious not to apply Gzip compression to large files or files that are already compressed. Most image and video formats are pre-compressed, and attempting to compress them on-the-fly at the web server level can significantly impact performance.

For Apache, you can implement this through the “AddOutputFilterByType” directive, as shown below:

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript

Optimize dispatcher cache:

Load Balancing and Failover:

  • Configure proper load balancing and failover mechanisms for multiple dispatcher instances.
  • Example: Set up a load balancer that distributes traffic based on a round-robin algorithm across multiple dispatcher instances.

Monitoring and Logging:

  • Implement monitoring and logging mechanisms to track the performance and cache hit rates of the dispatcher.
  • Example: Integrate the dispatcher with monitoring tools like New Relic to collect and analyze performance data in real time.

HTTPS Configuration:

  • Configuring the AEM Dispatcher to use HTTPS is crucial for both security and performance. Installing an SSL certificate and enforcing HTTPS ensures secure data transmission, enhances user privacy, and aligns with industry standards. While HTTPS introduces a slight overhead, modern optimizations mitigate its impact on speed. Furthermore, HTTPS can improve search engine ranking and user trust, indirectly enhancing the perceived speed and overall performance of your website.

Resource Minification and Concatenation:

Dispatcher optimizer tool

Enhance the cache hit ratio for your public-facing site, minimize the influence of unexpected or malicious requests, and mitigate the impact of activations on cached content. Achieving these objectives is made easier with the Dispatcher Optimizer Tool, abbreviated as DOT.

In its initial release, the DOT is available in two forms:

  • A Maven plugin for static configuration analysis during development
  • A code quality step in the Adobe Managed Services (AMS) Cloud Manager pipeline

A report from maven plugin would look like this:

For more info, please refer to link

SecureAEM Tool:

Adobe’s Security Checklist:

Implement the security checklist recommended by Adobe for Dispatcher. It provides expert-recommended measures to mitigate vulnerabilities, protect sensitive data, and prevent unauthorized access. By adhering to the checklist, you ensure compliance, build user trust, and proactively address evolving security threats, ensuring a secure and reliable digital experience. Link: https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/getting-started/security-checklist.html?lang=en

One thought on “Best Practices for a Dispatcher-Infused AEM Website

  1. Aanchal, your insights on optimizing AEM Dispatcher configurations are invaluable. The detailed best practices you shared will greatly enhance our website’s performance and security. Thank you for this comprehensive guide!

    Liked by 1 person

Leave a comment