Dispatcher and CDN Cache Troubleshooting for AEMaaCS

You’ve seen this one. A content author publishes a corrected headline, and ten minutes later half the team still sees the old text. Someone clears everything, the origin takes a load spike, and the page is still wrong for a few visitors. The cache wasn’t really the problem. Nobody knew which cache held the old copy.

In this lesson I’ll show you how to work out which layer is serving a stale page, using response headers, CDN logs and a cache-busting query parameter. Then you clear only that layer, in the right order, and check the result.

The examples use program 12345, environment 67890 and the project mysite.

Dispatcher and CDN Cache Troubleshooting for AEMaaCS - AEMCQ5Tutorials

Table of contents

Why this matters

Between the author and the visitor’s screen, an AEM as a Cloud Service page can sit in four different caches. Each has its own time to live and its own way of being cleared. Clear the wrong one and you waste time. Clear everything and you’ve made the most expensive mistake available.

✅ You’ll find the stale layer in minutes, not hours.
✅ You’ll clear one URL at one layer instead of the whole site.
✅ You’ll know which change needs a republish and which needs a CDN purge.
✅ You’ll be able to explain the fix to a content author in one sentence.

Who should read this

  • Developers who own the Dispatcher and CDN configuration for a project.
  • Operations engineers who pick up support tickets about stale content.
  • Content and release managers who want a safe way to publish corrections without guessing.

Prerequisites

Read Lesson 16, the Dispatcher SDK, first so the Dispatcher configuration makes sense to you. Lesson 18 covers replication and Sling content distribution, which is how a published page gets to the publish tier. Both are still unpublished drafts, so check the AEM Cloud roadmap for status.

For log access, read how to tail logs on AEM as a Cloud Service. You’ll need a Cloud Manager role that can download CDN logs, plus the purge key for the environment, stored as a pipeline secret.

The four cache layers

When a browser asks for a page on mysite, the request can pass through four caches. Each one decides how long to keep its copy, and each is cleared in a different way. The table shows the practical differences.

LayerWho sets its lifetimeHow you see itHow you clear it
BrowserThe Cache-Control header from the Dispatcher and CDN responses.Browser developer tools, Network panel, status shown as from disk cache.You cannot clear visitors’ browsers. Use a short lifetime and a versioned URL for assets.
Adobe CDNThe origin’s Cache-Control, Surrogate-Control or Expires headers. Surrogate-Control sets the CDN lifetime independently of the browser.CDN logs with the cache field, and the debug response header.Purge the URL with the Purge API. Dispatcher invalidation does not clear the CDN.
DispatcherThe cache rules, the vhost headers, and the farm’s enableTTL setting, which makes the Dispatcher respect expiry headers.The docroot inside the Dispatcher, the Age header, and the X-Vhost header when your vhost sets it.Activate or republish the page. Activation sends a flush to the Dispatcher automatically.
Publish instanceThe content in the repository, which is updated by replication.The page version in the Sites console and the replication status.Activate the page again. A replication problem is fixed at the author, not with a cache command.

Here’s the thing people forget: the CDN and the Dispatcher are separate caches. Republishing a page clears the Dispatcher copy, but the CDN keeps its own until its time to live expires or you purge it. This is the most common reason a fix shows up on some requests and not others.

Note:- By default, HTML is cached for five minutes in the browser, and the CDN respects the same value. If you add stale-while-revalidate (Adobe suggests 30 minutes as a starting point), a layer may keep serving the old copy while it refreshes in the background, so a fix can take a little while to appear. Responses with private, no-cache or no-store in Cache-Control, or with a Set-Cookie header, are never cached by the CDN.

Response headers and log fields that tell you where a response came from

Headers are the fastest evidence you’ve got. If a response carries a fresh Age value, a cache has held it for that long. The X-Vhost header only appears when your vhost sets it, so if it’s missing, treat that as missing evidence and not as proof that a cache answered.

SignalWhere it appearsWhat it tells you
Cache-ControlResponse header from the Dispatcher and CDNThe lifetime the layer was told to use. Compare it with what you expected.
AgeResponse headerHow long the response has been held in a cache. A value that grows between requests points to a cache hit.
X-VhostResponse header set by your vhostThe request reached the Dispatcher vhost. Its absence does not prove a cache answered.
cache fieldCDN logs, downloaded from the Download Logs dialogWhether the CDN served a HIT, a MISS, or passed the request through as a PASS.
BYOCDN debug headerRequest header x-aem-debug on a CDN requestUsed only for customer-managed (BYOCDN) CDN debugging. It is not needed for Adobe-managed CDN troubleshooting.

Note:- The field names above are the ones shown in the CDN logs and the headers listed here. Check them against your own responses before you rely on them in a runbook.

Hands-on: find the stale layer and clear only that layer

Here’s the scenario. The headline on /content/mysite/en/home.html was corrected in author an hour ago, and visitors in one region still see the old one. Run each step in order and write down what each one returns.

Step 1: Capture the response headers

Request the page through the public host and print only the headers. Look at Cache-Control, Age and X-Vhost, and whether the cache was hit.

curl -s -D - -o /dev/null https://www.mysite.example.com/content/mysite/en/home.html

Step 2: Check the CDN logs for the request

Download the Publish CDN logs from the Download Logs dialog in Cloud Manager (the same one we used in Lesson 15) and search for the page path. Each log line is a JSON object. The cache field tells you whether the CDN answered from its cache (HIT), fetched from the origin (MISS) or passed the request through (PASS), and res_age shows how long it had held the copy. CDN logs can lag by up to five minutes, so request the page first and then wait.

grep '/content/mysite/en/home.html' cdn-publish-logs.log | tail -n 3

Step 3: Use a cache-busting query parameter

Request the page with a query parameter that changes on every call, such as cb. A new query string means a new cache key at the CDN, so the request goes on to the Dispatcher. If the fresh headline shows up, the CDN was the stale layer. If you still get the old headline, the stale copy lives in the Dispatcher or on the publish tier.

curl -s "https://www.mysite.example.com/content/mysite/en/home.html?cb=$(date +%s)" | grep -i "<title>"
curl -s https://www.mysite.example.com/content/mysite/en/home.html | grep -i "<title>"

Stick with a neutral name such as cb. A parameter that looks like a tracking code can be treated differently from an ordinary one, and that will confuse your test.

Step 4: Check that the publish state is current

In the Sites console, open the page and check that the published version is the one you expect. If author shows the new headline but the page was last activated before the change, replication never ran for the latest edit. Then republishing is the fix, not a cache command.

Step 5: Republish the page to clear the Dispatcher

Activate the page from the Sites console. Activation sends a flush request to the Dispatcher, which removes the cached copy of the page and its parents up to the level set by statfileslevel. There’s no need to flush the whole site. Repeat the request from Step 1 and confirm the new headline appears.

Note:- If republishing doesn’t clear the Dispatcher, check that a vhost matches localhost, 127.0.0.1, *.local, *.adobeaemcloud.com and *.adobeaemcloud.net. Dispatcher invalidation depends on it. The Dispatcher SDK lesson (Lesson 16) shows how to keep that vhost.

curl -s https://www.mysite.example.com/content/mysite/en/home.html | grep -i "<title>"

Step 6: Purge the CDN for that URL

Say the cache-busting request in Step 3 showed the new headline, but the plain request still shows the old one. Then the CDN is the stale layer. Purge only that URL, and do it after the Dispatcher is fresh. Purge the CDN first and the next miss fetches the stale Dispatcher copy and stores it all over again.

curl -X PURGE "https://publish-p12345-e67890.adobeaemcloud.com/content/mysite/en/home.html" \
  -H "X-AEM-Purge-Key: $PURGE_KEY" \
  -H "X-AEM-Purge: soft"

The purge key is declared in your CDN configuration through a config pipeline (see Lesson 15), and here it’s read from an environment variable in your shell. Don’t paste it into a script or a commit. The default purge is a hard purge, so the content is unavailable until the origin responds. The X-AEM-Purge: soft header used above marks it stale but keeps serving it. With a customer-managed CDN, also send X-AEM-Edge-Key and X-Forwarded-Host.

Step 7: Verify the result

Request the page twice. The first request after a purge should show a MISS in the CDN logs and the second a HIT, and both should return the corrected headline. Then note the layer you cleared and the time in your incident notes. You’ll thank yourself later.

Choosing a safe invalidation method

Each method clears a different amount of cache and costs your origin a different amount of load. Start with the smallest one that fixes the problem.

MethodWhat it clearsWhen to use itCaution
Republish the pageThe Dispatcher copy of the page and its parents up to statfileslevelAny normal content changeDoes not touch the CDN.
Soft purge of one URLThe CDN copy of one URL, which can be served stale while it is refreshedOne page is wrong at the CDNThe next miss sends a request to the origin.
Hard purge of one URL (the default)The CDN copy of one URL, which is not served until the origin respondsA sensitive page must not be served at allVisitors wait for the origin, so origin load rises.
Purge by surrogate keyEvery CDN copy whose response carries that Surrogate-KeyOne change touches many URLs, such as a shared fragmentThe key must be on the responses before you purge. Soft or hard, as for one URL.
Purge allThe whole CDN cache for the environmentLast resort, such as a broken deploymentCan cause an origin spike and an outage.

Single-URL and surrogate-key purges take the same X-AEM-Purge header. Leave it out for a hard purge, or send soft. A full purge needs X-AEM-Purge: all. I’d go with a soft purge for one URL and keep hard purges for when stale content truly isn’t acceptable. To purge by surrogate key, add a Surrogate-Key header to your responses first, then send the key in the purge request:

curl -X PURGE "https://publish-p12345-e67890.adobeaemcloud.com" \
  -H "X-AEM-Purge-Key: $PURGE_KEY" \
  -H "Surrogate-Key: home-hero" \
  -H "X-AEM-Purge: soft"

Common mistakes and troubleshooting

Most stale-content incidents come down to clearing the wrong layer, or clearing the right ones in the wrong order. The table lists the patterns I’d check first.

SymptomLikely causeWhat to do
The fix appears for some visitors but not othersThe CDN holds a copy that the Dispatcher has already cleared.Purge the CDN URL after the Dispatcher is fresh, and check the cache-busting request.
A CDN purge brought back the old contentThe Dispatcher still held the stale copy when the CDN fetched again.Republish the page first, then purge the CDN URL.
Republishing did not change the responseThe page was not activated after the last edit, or replication failed.Check the publication status in the Sites console and activate the page again.
Content is stale for hours on every requestA long lifetime on HTML responses.Shorten the lifetime for HTML, and keep long lifetimes for versioned assets only.
A purge caused a spike in origin requestsA hard purge (the default) or a purge-all was used for a normal change.Use republish for content changes, and soft purge for single URLs.
The Dispatcher returns a page that ignores a query parameterThe Dispatcher ignores that parameter in its cache key.Check the ignoreUrlParams setting before you rely on a parameter to bust the cache.
Only one browser shows the old pageThe browser cache holds the response.Ask the user to reload, and check the Cache-Control lifetime for next time.
The CDN never serves the page from cacheThe response has private, no-cache or no-store in Cache-Control, or it sets a cookie.Remove them for public pages, or accept a MISS on every request.

Hands-on challenge

Simulate a stale page in a dev environment and fix it in the correct order. Write down your decision at each step.

  1. Change the headline of /content/mysite/en/home.html on author and activate the page.
  2. Request the page with and without a cache-busting parameter. Decide which layer is stale using only the headers and the logs.
  3. Clear that layer with the smallest method that works. If you purge the CDN, do it after the Dispatcher is fresh.
  4. Write a two-line runbook entry: the symptom, the layer and the method you used.

Compare your runbook entry with the table in the safe invalidation section. If you purged when a republish would have been enough, work out why and fix the entry.

Key takeaways

  • A page can be stale in the browser, the CDN, the Dispatcher or the publish tier. Find the layer before you clear anything.
  • Republishing clears the Dispatcher, but the CDN keeps its copy.
  • Purge the CDN after the Dispatcher is fresh, or the CDN will happily fetch the stale copy again.
  • The Adobe CDN purges hard by default. Send X-AEM-Purge: soft for one URL, and keep purge-all as a last resort.
  • For every stale-content incident, write down the layer, the method and the time.

Knowledge check

Have a go at each question before you expand the answer.

1. Why should you invalidate the Dispatcher before purging the CDN?

On a miss, the CDN fetches from the Dispatcher. If the Dispatcher still holds the stale copy, the purge just brings the stale content back.

2. Does republishing a page clear the Adobe CDN?

No. Republishing clears the Dispatcher copy. The CDN keeps its own copy until its lifetime expires or you purge the URL with the Purge API.

3. What does a soft purge do differently from a hard purge?

A soft purge can keep serving the stale copy while it refreshes. A hard purge isn’t served until the origin responds, so the load on your origin goes up.

4. Why use a neutral query parameter such as cb for cache-busting?

A cache-busting parameter gives the request a new cache key at the CDN, so it reaches the Dispatcher. A parameter that looks like a tracking code may be handled differently, which muddies the test.

5. Which method clears a single page at the Dispatcher after a normal content change?

Republish the page. Activation sends a flush to the Dispatcher for the page and its parents, up to the statfileslevel setting.

Frequently asked questions

Can I clear the browser cache for my users?

No, you can’t clear a visitor’s browser. Keep the lifetime of HTML responses short, and use versioned URLs for assets so a new release gets fetched.

Does calling the publish host skip the CDN?

No. Requests to the publish host still pass through the Adobe CDN, so its cache applies to them too.

Why does my purge show success but the page is still stale?

Check the order first. If the Dispatcher still holds the old copy, the CDN fetches it again after the purge. Republish the page, then purge, and verify with the cache-busting request.

Should I purge after every content change?

No. Activation handles a normal content change. Purge only when the CDN is wrong, or when the content must not be served at all.

Continue your learning

References

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.