Cache purging in Azure Front Door with Azure PowerShell

Applies to: ✔️ Front Door Standard ✔️ Front Door Premium

Azure Front Door caches assets until their time-to-live (TTL) expires. When a client requests an asset with an expired TTL, Azure Front Door retrieves and caches a new copy of the asset.

To ensure users always get the latest assets, version your assets for each update and publish them with new URLs. Azure Front Door fetches the new assets for subsequent client requests. However, you might need to purge cached content from all edge nodes to force them to retrieve updated assets, especially after making updates or correcting incorrect information.

Prerequisites

  • An Azure account with an active subscription. Create an account.
  • Azure PowerShell installed locally.

Note

We recommend that you use the Azure Az PowerShell module to interact with Azure. See Install Azure PowerShell to get started. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

Configure Cache Purge

Use the Clear-AzFrontDoorCdnEndpointContent cmdlet to purge cache by specifying parameters such as:

  • Resource group name.
  • Azure Front Door profile name within the resource group.
  • Endpoints with assets to purge.
  • Domains/Subdomains with assets to purge.

Important

Cache purge for wildcard domains is not supported. Specify subdomains for cache purge in wildcard domains. For example, for the wildcard domain *.afdxgatest.azfdtest.xyz, use subdomains like contoso.afdxgatest.azfdtest.xyz or cart.afdxgatest.azfdtest.xyz. For more information, see Wildcard domains in Azure Front Door.

  • Path to the content to be purged:
    • Single path purge: Specify the full path of the asset (without the protocol and domain), including the file extension, for example, /pictures/strasbourg.png.
    • Root domain purge: Purge the root of the endpoint with "/*" in the path.
Clear-AzFrontDoorCdnEndpointContent `
    -ResourceGroupName myRGFD `
    -ProfileName contosoafd `
    -EndpointName myendpoint `
    -Domain www.contoso.com `
    -ContentPath /scripts/*

Cache purges on the Azure Front Door profile are case-insensitive and query string agnostic, meaning purging a URL purges all its query-string variations.

Note

Cache purging can take up to 10 minutes to propagate throughout the network and across all edge locations.

Next steps

Learn how to create an Azure Front Door profile.