Skip to content
All writing ‹ Part 08 of 18 · A Cache Is a Chain, Not a Box
Engineering · 2 min read

Akamai Tools: Purge and CLI

Using the Akamai CLI to check a file, purge it, and check again. Invalidate versus delete, how to read x-cache, and why a purge reaches only the CDN layer.

I used the Akamai CLI to run one cycle: check the file, purge, then check again.

After a file changes, users still see the old version. The first thing most people think of is purge. I wanted to understand what a purge really does.

Two Kinds of Purge

InvalidateDelete
ActionMark the copy as expiredRemove the copy
Next requestAsks with the ETag, may get a 304Downloads the whole file again
Origin loadLowHigh
UseNormal updatesThe old version must never appear again
  • We have several upload services. Only a few of them call purge. The others rely only on TTL expiry.

Common Commands

curl -sI "https://cdn.example.com/assets/{id}/{file}"   # note the date and etag
akamai --section default purge invalidate --staging "<url>"  # credentials in ~/.edgerc

After the purge, wait 5 seconds and run curl again (add Pragma: akamai-x-cache-on):

 HTTP/2 200
 etag: "32b7140e..."
-date: Sat, 18 Oct 2026 08:00:00 GMT
-x-cache: TCP_HIT from a23-...
+date: Sat, 18 Oct 2026 08:05:07 GMT
+x-cache: TCP_REFRESH_HIT from a23-...
  • x-cache changed from TCP_HIT to TCP_REFRESH_HIT: the copy became expired, and the edge went back to the origin to ask.
  • etag did not change: the content is the same. The origin returned 304, and the edge kept the original copy (Cache Freshness: Fresh, Stale, and 304).

A purge reaches only the CDN layer. At that time I thought there was no other cache behind the origin. So I believed that after a CDN purge I would always get the new file. Later I found this belief was wrong (Two Cache Layers: What I Believed).

A purge clears the layer you can see. The layer you cannot see puts the old file back.

Sources: Akamai: EdgeGrid, Akamai: purge methods

Related: Cache Freshness: Fresh, Stale, and 304, Akamai Property: One Edge Config, Two Cache Layers: What I Believed. Or go back to the series overview.

↑↓ navigate ↵ open esc close