|
| 1 | +--- |
| 2 | +title: 'Cache purging - Azure Front Door - Azure PowerShell' |
| 3 | +description: This article helps you understand how to purge cache on an Azure Front Door Standard and Premium profile using Azure PowerShell. |
| 4 | +services: frontdoor |
| 5 | +author: duongau |
| 6 | +manager: KumudD |
| 7 | +ms.service: frontdoor |
| 8 | +ms.topic: how-to |
| 9 | +ms.workload: infrastructure-services |
| 10 | +ms.date: 09/20/2022 |
| 11 | +ms.author: duau |
| 12 | +--- |
| 13 | + |
| 14 | +# Cache purging in Azure Front Door with Azure PowerShell |
| 15 | + |
| 16 | +Azure Front Door caches assets until the asset's time-to-live (TTL) expires. Whenever a client requests an asset with expired TTL, the Azure Front Door environment retrieves a new updated copy of the asset to serve the request and then stores the refreshed cache. |
| 17 | + |
| 18 | +Best practice is to make sure your users always obtain the latest copy of your assets. The way to do that is to version your assets for each update and publish them as new URLs. Azure Front Door Standard/Premium will immediately retrieve the new assets for the next client requests. Sometimes you may wish to purge cached contents from all edge nodes and force them all to retrieve new updated assets. The reason you want to purge cached contents is because you've made new updates to your application, or you want to update assets that contain incorrect information. |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F). |
| 23 | +- Azure PowerShell installed locally or Azure Cloud Shell |
| 24 | + |
| 25 | +[!INCLUDE [updated-for-az](../../../includes/updated-for-az.md)] |
| 26 | + |
| 27 | +[!INCLUDE [cloud-shell-try-it.md](../../../includes/cloud-shell-try-it.md)] |
| 28 | + |
| 29 | +* Review [Caching with Azure Front Door](../front-door-caching.md) to understand how caching works. |
| 30 | +* Have a functioning Azure Front Door profile. Refer [Create a Front Door - PowerShell](../create-front-door-powershell.md)to learn how to create one. |
| 31 | + |
| 32 | +## Configure cache purge |
| 33 | + |
| 34 | +Run [Clear-AzFrontDoorCdnEndpointContent](/powershell/module/az.cdn/clear-azfrontdoorcdnendpointcontent) to purge cache after inputting the necessary parameters like: |
| 35 | + * Name of resource group |
| 36 | + * Name of the Azure Front Door profile within the resource group with assets you want to purge |
| 37 | + * Endpoints with assets you want to purge |
| 38 | + * Domains/Subdomains with assets you want to purge |
| 39 | + |
| 40 | + > [!IMPORTANT] |
| 41 | + > Cache purge for wildcard domains is not supported, you have to specify a subdomain for cache purge for a wildcard domain. You can add as many single-level subdomains of the wildcard domain. For example, for the wildcard domain `*.afdxgatest.azfdtest.xyz`, you can add subdomains in the form of `contoso.afdxgatest.azfdtest.xyz` or `cart.afdxgatest.azfdtest.xyz` and so on. For more information, see [Wildcard domains in Azure Front Door](../front-door-wildcard-domain.md). |
| 42 | +
|
| 43 | + * The path to the content to be purged. |
| 44 | + * These formats are supported in the lists of paths to purge: |
| 45 | + * **Single path purge**: Purge individual assets by specifying the full path of the asset (without the protocol and domain), with the file extension, for example, /pictures/strasbourg.png. |
| 46 | + * **Root domain purge**: Purge the root of the endpoint with "/*" in the path. |
| 47 | + |
| 48 | +```azurepowershell-interactive |
| 49 | +Clear-AzFrontDoorCdnEndpointContent ` |
| 50 | + -ResourceGroupName myRGFD ` |
| 51 | + -ProfileName contosoafd ` |
| 52 | + -EndpointName myendpoint ` |
| 53 | + -Domain www.contoso.com ` |
| 54 | + -ContentPath /scripts/* |
| 55 | +``` |
| 56 | +Cache purges on the Azure Front Door profile are case-insensitive. Additionally, they're query string agnostic, which means to purge a URL will purge all query-string variations of it. |
| 57 | + |
| 58 | +## Next steps |
| 59 | + |
| 60 | +Learn how to [create an Azure Front Door profile](../create-front-door-portal.md). |
0 commit comments