Content Delivery with AEM Dispatcher: A Beginner’s Overview


Today, we’re diving into the world of the Adobe Experience Manager (AEM) Dispatcher, unravel mysteries and show you why the AEM Dispatcher is the unsung hero of delivering top-notch web experiences.

Dispatcher Demystified: What is it, Anyway?

Let’s start at the beginning. Ever visited a website and marveled at how fast it loaded? Chances are, the AEM Dispatcher played a role in making that happen. It’s like the traffic controller for your website, managing requests and serving up cached content faster.

Cache It Right: The Rebel Rules

Hold up, don’t think for a second that there’s a single rulebook for caching. Nah, it’s more like a “choose your adventure” kind of deal. Your app’s like a buffet with a mix of public, private, and secret sauce content. Caching needs to know what’s meant for everyone’s eyes, what’s top-secret, and what’s in between.

Invalidation Drama

Imagine changing your profile pic and your old one still haunting your social media. Not cool, right? Same goes for your app. When stuff changes, cached content needs to get a memo and update accordingly. That’s where the AEM Dispatcher’s Invalidation comes into play. It’s like a heart-to-heart chat for cached content, ensuring it’s always up-to-date.

From User to Experience: How the AEM Dispatcher Delivers Web Content

  1. User Sends a Request: A user initiates a request by entering a URL in their web browser to access a specific page or resource on the website.
  2. Request Reaches Dispatcher: The request reaches the Dispatcher, which acts as a reverse proxy. The Dispatcher is responsible for handling incoming requests on behalf of the AEM publish instances.
  3. Dispatcher checks if its a cacheable request. If cacheable, it check’s web server’s cache, else requests AEM publish to render the response.
  4. Dispatcher Cache Check: The Dispatcher checks if the requested content is already present in its cache. If the content is cached and valid, the Dispatcher serves the cached content directly to the user, leading to faster response times.
  5. Cache Miss or Invalidation: If the requested content is not in the cache or if it has been invalidated (e.g., due to updates by content authors), the Dispatcher sends a request to the AEM publish instances to fetch the latest content.
  6. Publish Instance Handling: The request reaches one of the AEM publish instances. The publish instance processes the request, generating dynamic content by querying the AEM repository and applying templates, components, and other configurations.
  7. Content Rendering: The AEM publish instance renders the requested content into HTML, including the dynamic data and components specific to that page.
  8. Response to Dispatcher: The AEM publish instance sends the rendered HTML response back to the Web server.
  9. Caching and Content Delivery: If caching is enabled and the response is cacheable, the Dispatcher stores the rendered HTML and static assets in its cache for future use.
  10. Dispatcher Response: The Dispatcher forwards the cached or newly fetched content to the user’s browser, which then displays the webpage to the user.

For more details, please refer to link

Dispatcher caching

We’ll break down the nuts and bolts of how the AEM Dispatcher operates. From flushing strategies to cache invalidation, we’ll unravel the magic behind the scenes that keeps your website fresh and zippy.

How does an AEM dispatcher’s cache look like?

When a request is made to the dispatcher, the response that can be cached is stored in the web server’s cache. These cacheable responses are organized in a hierarchical format under the document root (also known as “docroot”) folder. The docroot folder is the top-level directory where the web server serves its content from, and it usually represents the root of your website’s file structure.

The hierarchical structure in which the cached documents are stored reflects the URL structure of the requests. This architecture aids in easy navigation through the cache, as the arrangement closely mirrors the layout of the requests. For instance, consider the following example URL: http://localhost:8080/content/wknd/language-masters/en/adventures.html. In this case, the corresponding cache structure might appear something like this:

Here, adventures.html represents the HTML response fetched from the publish server. Within the adventures folder, you would find various resources such as images and more. These resources are organized according to the paths specified in the HTML source code, ensuring that the structure of the cache mimics the dependencies of the webpage.

What are the .h files?

In general, the .h files in the context of AEM Dispatcher caching serve as containers for HTTP response headers that are associated with the corresponding cached files. These headers provide critical information about the content type, content disposition, modification details, and security precautions. By including such headers, these .h files contribute to the proper rendering, handling, and security of the cached content when served to users’ browsers or clients.

For adventures.html.h:

Content-Type: text/html;charset=utf-8
X-Content-Type-Options: nosniff
  • The Content-Type header specifies that the content is in HTML format with a UTF-8 character encoding.
  • The X-Content-Type-Options header with the value nosniff instructs browsers not to try to infer or “sniff” the content type. This enhances security by preventing certain attacks based on MIME type confusion.

Purpose: The purpose of the adventures.html.h file is to provide HTTP response headers for the HTML content of the “adventures.html” page. These headers ensure that the browser correctly interprets the content as HTML and adheres to security best practices to prevent any content type-related vulnerabilities.


For adobestock-278302117.jpeg.h:

Content-Disposition: inline; filename=adobestock-278302117.jpeg
Content-Type: image/jpeg
Last-Modified: Fri, 12 Aug 2022 17:03:06 GMT
X-Content-Type-Options: nosniff
  • The Content-Disposition header with the value inline; filename=adobestock-278302117.jpeg suggests that the browser should display the image inline and use the specified filename when saving it.
  • The Content-Type header indicates that the content is an image in JPEG format.
  • The Last-Modified header provides the last modification date of the image file.
  • The X-Content-Type-Options header with the value nosniff is a security measure to prevent MIME type confusion attacks.

Purpose: The purpose of the adobestock-278302117.jpeg.h file is to provide HTTP response headers for the JPEG image. These headers define how the browser should display the image, the content type, when the image was last modified, and enforce security measures to ensure the proper handling of the image content.

Cache Flushing Strategies:

Beneath the surface, the AEM Dispatcher employs a variety of cache flushing strategies to intelligently manage the cached content. Dispatcher strategically decides which content to flush and when, striking a balance between content freshness and optimal performance.

These strategies take into account various factors such as content update frequency, user access patterns, and overall system resources. Let’s delve deeper into these cache flushing strategies:

1. Content Invalidation:

When content is updated or modified in the AEM instances, the Dispatcher utilizes content invalidation mechanisms to ensure that the outdated cached content is removed. This ensures that users are served with the most current content while minimizing unnecessary cache purges.

Invalidation Based on Folders

To remove stored files from the cache based on their folder hierarchy, you can use the “/statfileslevel” setting:

The Dispatcher, which manages caching, generates special “.stat” files in each folder from the main folder to a certain level you set. The main folder is considered level 0.

When you invalidate a file at a specific level, all “.stat” files from the main folder to that level or the designated “statfileslevel” (whichever is lower) are updated.

This process affects only resources along the path to the invalidated file. For example, imagine a website using the structure: /content/abc/us/en/. If you set “statfileslevel” to 4, a “.stat” file is generated as shown below:

  1. docroot
  2. /content
  3. /content/abc
  4. /content/abc/us/
  5. /content/abc/us/en/

When you invalidate a file in /content/abc/us/en/… , all “.stat” files from the docroot down to /content/abc/us/en are updated. This applies only to the /content/abc/us/en/… scenario, not to other paths like /content/abc/us/es.

Importance of optimizing statfileslevel

Having a higher statfileslevel in the context of cache invalidation using .stat files is important for more efficient cache management and better control over which cached files are invalidated.

The statfileslevel setting determines how far up the folder hierarchy the .stat files are created and checked for cache invalidation. When you set a higher statfileslevel, you’re telling the system to create and manage .stat files at a broader level in the folder structure. Here’s why having a higher statfileslevel can be important:

  • Faster Cache Invalidation: When you make a change to a resource (e.g., a webpage) in a particular folder, the associated .stat file is updated to reflect the change. If the statfileslevel is set higher, it means more .stat files are present in upper-level folders. When any of these higher-level .stat files are updated due to a change in a lower-level resource, it can trigger a broader cache invalidation, making the updated content reflect faster across multiple pages or sections.
  • Avoiding Under-Caching: If you set a lower statfileslevel, only the .stat files in the immediate parent folders might be updated upon a change. This could lead to under-caching, where some related content remains cached despite changes being made.
  • Consistency Across Site Sections: Websites often have a hierarchy of content, with various sections and subsections. With optimum statfileslevel, changes in one section can quickly propagate to related sections through cache invalidation, creating a more consistent experience for users.

statfileslevel allows you to manage cache invalidation with finer granularity. You can control which levels of your website’s structure are affected by changes in specific folders. This flexibility helps prevent over-invalidation, where unnecessary cache clearing impacts performance.

The ideal statfileslevel varies depending on your website’s structure, content update frequency, and the nature of your caching requirements. It’s important to monitor and test different settings to determine what works best for your specific use case.

Note: As a default behavior, not all of this content will undergo invalidation. Normally, only .html files would go through this process, though customization is possible through the /invalidate rule.

2. Time-Based Expiration:
Cache entries may be assigned expiration times based on content characteristics or predefined rules. Time-based expiration strategies remove content from the cache after a specified period, ensuring that users receive updated content if it has not been refreshed within a certain timeframe. This strategy is useful for time-sensitive content and maintaining content freshness.

3. Combining Strategies:
In many cases, a combination of cache flushing strategies may be employed simultaneously. This holistic approach allows the Dispatcher to adapt to various content types, usage scenarios, and resource constraints effectively.

For more details on Cache Flush strategies, refer to link

Security Shield

The AEM Dispatcher serves as a vigilant gatekeeper, standing between incoming web requests and your AEM instance. It acts as the first line of defense, preventing unauthorized or potentially harmful requests from ever reaching your server. By intercepting incoming traffic, the Dispatcher not only enhances performance but also significantly bolsters your security posture.

Filtering and Sanitizing Incoming Requests:
One of the Dispatcher’s primary responsibilities is to scrutinize incoming requests meticulously. It employs a series of filters and validation mechanisms to ensure that only legitimate and safe requests are allowed through. Suspicious requests, such as cross-site scripting (XSS) attacks, are swiftly intercepted and neutralized, preventing any potential exploitation of vulnerabilities in your AEM instance.

Thwarting Malicious Attacks:
Malicious actors continuously probe for weaknesses in web applications. The Dispatcher’s proactive approach foils these attempts by promptly identifying and blocking malicious traffic. By blocking threats at the edge, before they even reach your content management system, the Dispatcher offers a powerful defense mechanism, reducing the attack surface and fortifying your AEM environment.

Benefits of Dispatcher-Driven Security:

  • Reduced Attack Surface: The Dispatcher significantly narrows the exposure of your AEM instance to the public internet, minimizing the potential points of entry for attackers.
  • Performance Boost: Alongside its security functions, the Dispatcher’s role in caching and load balancing further enhances performance, delivering content swiftly to legitimate users.
  • Protection for Zero-Day Vulnerabilities: Even if new vulnerabilities emerge, the Dispatcher can be configured to provide temporary protection until a proper fix is implemented.

Key Responsibilities of the AEM Dispatcher

The AEM Dispatcher’s role extends beyond caching and performance optimization. Understanding its multifaceted responsibilities empowers you to harness its full potential in crafting robust and resilient digital experiences.

  1. Caching: The Dispatcher acts as a reverse proxy server that caches content from an AEM instance. It stores static and dynamic content generated by AEM in its cache. When users request content from the website, the Dispatcher checks if the requested content is available in its cache. If it is, the Dispatcher serves the cached content directly, reducing the load on the AEM server and improving response times.
  2. Load Balancing: The Dispatcher can distribute incoming user requests across multiple AEM instances to balance the load. This helps distribute the processing power and prevents any single server from becoming overloaded. Load balancing is crucial for maintaining the performance and availability of the website, especially during high traffic periods.
  3. Security: The Dispatcher can also play a role in enhancing security by filtering and sanitizing requests before they reach the AEM instance. It helps prevent malicious requests from reaching the server and potentially causing security vulnerabilities.
  4. Content Delivery Network (CDN) Integration: The Dispatcher can be integrated with CDNs to deliver cached content from edge locations that are closer to the end-users, reducing latency and improving content delivery speed.
  5. Reducing Server Load: By serving cached content directly and offloading repetitive requests, the Dispatcher helps decrease the load on the AEM server, enabling it to focus on serving dynamic content and reducing the risk of server overloads.
  6. Offline Availability: Cached content provided by the Dispatcher ensures that users can still access parts of the website even if the AEM instance is temporarily unavailable. This can enhance the user experience during maintenance or unexpected server outages.

In conclusion, mastering the basics of the AEM Dispatcher is a fundamental step towards achieving exceptional web performance and content delivery in Adobe Experience Manager. As you continue your journey with AEM, a deep understanding of the Dispatcher’s role will empower you to navigate the complexities of modern web architecture and create dynamic, lightning-fast digital experiences that captivate your audience. Happy dispatching!

For the curious ones:

Visit link for more dispatcher experiments

One thought on “Content Delivery with AEM Dispatcher: A Beginner’s Overview

Leave a comment