Setup AEM Dispatcher Configuration for Optimal Performance AEM

Including AMS virtual host configures AEM settings for domain handling within Adobe Managed Service. It's an essential step when implementing an AEM instance under AMS for proper domain-specific configuration.

We have default.vhost, then you can establish flagtick.vhost files from /etc/httpd/conf.d/availabled_vhosts/ directory get symlink into the /etc/httpd/conf.d/enabled_vhosts/ directory they will be used in the running configuration.

Look at the source code of the AEM project locally as an example. In the code, identify two areas that will be circled with different colors:

  • Blue: Represents AMS Top Level Includes
  • Red: Represents AMS Virtual Host Includes

To setup Cache-Control: max-age=86382, public header for images in a virtual host on a web server, you will typically need to configure this based on the specific web server you are using.

Apache HTTP Server:

<FilesMatch "\.(jpg|jpeg|png|gif|ico|svg)$">
    Header set Cache-Control "max-age=86382, public"


location ~* \.(jpg|jpeg|png|gif|ico|svg)$ {
    add_header Cache-Control "max-age=86382, public";

We have another approach using the <LocationMatch> directive, typically employed in Apache configurations to match URLs. This directive sets the Cache-Control header for specific file types within the specified location pattern.

<LocationMatch "^/content/.*\.(?i:jpe?g|gif|js|mov|png|svg|txt|zip|pdf|ico)$">
    Header set Cache-Control "max-age=1800,s-maxage=86400,stale-while-revalidate=43200,stale-if-error=43200"

The absence of the public directive in the Cache-Control header implies that the response is intended for a single user and is not considered publicly cacheable. The public directive, when present, allows caching by intermediate proxies and other users.

<LocationMatch "^/content/.*\.(?i:jpe?g|gif|js|mov|png|svg|txt|zip|pdf|ico)$">
    Header set Cache-Control "max-age=1800, public, s-maxage=86400, stale-while-revalidate=43200, stale-if-error=43200"

As you dive into the details of the image URL, you'll observe that accessing the URL via Port 80 results in the response header 'X-Cache: HIT.' This indicates a successful attempt to retrieve data from the cache. However, if the content is not found in the cache, it doesn't imply a failure; rather, it may trigger a fetch from the origin server.

curl -I http://flagtick.com/content/dam/flagtick/logos/Background.svg
HTTP/1.1 301 Moved Permanently
Connection: close
Content-Length: 0
Retry-After: 0
Location: https://flagtick.com/content/dam/flagtick/logos/Background.svg
Accept-Ranges: bytes
Date: Wed, 24 Jan 2024 02:56:47 GMT
Strict-Transport-Security: max-age=31557600
X-Served-By: cache-hkg17931-HKG
X-Cache: HIT
X-Timer: S1706065008.743288,VS0,VE1

On the opposite, accessing the same URL via Port 443 yields the response header 'X-Cache: MISS,' signaling that the system attempted to retrieve the content from the cache but couldn't find it.

curl -I https://flagtick.com/content/dam/flagtick/logos/Background.svg
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 645396
Content-Type: image/svg+xml
Content-MD5: haOS3BTaG9CLVsQ/dxslFQ==
Last-Modified: Fri, 16 Sep 2022 07:58:10 GMT
Accept-Ranges: bytes
ETag: "0x8DA97B932F7322B"
Access-Control-Allow-Origin: *
Cache-Control: private, max-age=600, immutable
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
content-disposition: attachment; filename="Background.svg"
x-vhost: publish
Date: Wed, 24 Jan 2024 03:21:44 GMT
Strict-Transport-Security: max-age=31557600
X-Served-By: cache-hkg17934-HKG
X-Cache: MISS
X-Timer: S1706066504.713061,VS0,VS0,VE783

It's crucial to note that the caching configuration for Port 80 do not override that of Port 443. Let us go to each part of the Dispatcher. First and foremost, let's go to the Caching section with HTML/Text. Follow up with the link here:

» src/conf.d/variables/custom.vars


» src/conf.d/available_vhosts/flagtick.vhost

<LocationMatch "^/content/${CONTENT_FOLDER_NAME}/us/en/(.*).html$">
     Header set Cache-Control "max-age=1800,public"

Reference link: https://experienceleague.adobe.com/docs/experience-manager-learn/ams/dispatcher/explanation-config-files.html?lang=en

You need to login to do this manipulation!