Skip to main content

Cache purge

Cache purge (also called "cache clearing") is the process by which URLs are removed from Akamai cache. After a URL is removed from Akamai cache, the next time that URL is requested, Akamai will forward the request to the origin (i.e. Sitecore CD). Details on the process is available in the Akamai reference documentation.

note

Cache purge is also called cache clearing. In general, "purge" is used to describe the process from Akamai's perspective, while "clearing" is used from Sitecore's perspective.

Triggering#

There are several ways to start the Akamai cache purge process.

Automated#

Automated cache purge involves Uniform sending cache purge instructions to Akamai when publishing finishes. By default, automated cache purge is disabled. The installation instructions includes information on how to enable automated cache purge.

Details about how automated cache purge works are available in the reference section.

Manual#

Sitecore users can manually trigger Akamai cache purge operations using the Content Editor ribbon. Uniform adds a tab named "Uniform" to the ribbon. In this tab there is button "Clear Akamai cache" that enables you to trigger a purge operation for the selected item.

Full site purge and item purge are supported, depending on the item selected in the Content Editor:

  • Full-site purge - When an item based on the template "Sitecore Site Item" is selected.
  • Item purge - When a content item or media item is selected.
note

A custom Sitecore pipeline is used to determine whether the button triggers a full-site purge or an item purge. For details on this pipeline, see the reference section on is full-site purge.

By default, the button is only enabled when the selected item matches one of the following conditions:

  • Is a content item.
  • Is a media item.
  • Is based on the template "Sitecore Site Item".
note

A custom Sitecore pipeline is used to determine whether the button is enabled. For details on this pipeline, see reference section on purgeable items.

Programmatic#

Akamai cache purge can be triggered using the Uniform API. The following code sample demonstrates how:

//Get an item from somewhere...Sitecore.Data.Items.Item item = null;
//Get the home item for the site.var homeItem = Sitecore.Context.Site.GetHomeItem(Sitecore.Context.Database);
//Get the dependent pages for the item.var args = new Uniform.Pipelines.GetDependentPages.GetDependentPagesArgs(item, homeItem);Uniform.Pipelines.GetDependentPages.GetDependentPagesPipeline.Run(args);
//Get the item ids for the dependent pages.var itemIds = args.DependentPages.Select(i => i.ID);
//Get the component that sends cache purge commands to Akamai.var provider = new Uniform.Cache.AkamaiCacheProvider();
//Send the cache purge command.var args2 = new Uniform.Cache.PurgeArgs("my-site", Sitecore.Context.Database, itemIds);var results = provider.Purge(args2);

Troubleshooting#

Akamai Control Center#

The Akamai Control Center provides debugging tools to help you understand how the state and operation of the Akamai cache.

note

This documentation is not a replacement for Akamai's product documentation. This section is included to provide some high-level troubleshooting guidance.

Cache hits & misses#

If your pages are taking longer to load than expected, it is possible that the page isn't being cached. Akamai provides the ability to determine whether a request hits or misses the Akamai cache.

  1. In Akamai Control Center, navigate to SUPPORT > Diagnostic tools.

  2. In the section "Service Debugging Tools", click Debug URL.

  3. Enter the URL you want to check if it is in the Akamai cache and click Submit.

    note

    This request will not change the state of the Akamai cache. For example, if the URL is not cached, using this tool will load cause the URL to be added to the cache.

  4. On the tab HTTP Response, the field "Cache Setting" indicates whether the URL is in Akamai cache or not:

    • TCP_MISS means the URL is not cached
    • TCP_HIT means the URL is cached

Enable debug mode#

When Akamai debug mode is enabled, detailed information about API calls made to Akamai are written to the Sitecore log with the following details:

  • Log level: INFO
  • Message prefix: [Akamai Debug]

Akamai debug mode is controlled through a Sitecore config setting. By default debug mode is disabled. It can be enabled using the following setting:

<setting name="Uniform.Akamai.DebugMode" value="true" />
note

Akamai debug mode will include detailed information about purge commands sent to Akamai, including the JSON object that describes what to purge from the cache.