AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Calls the Amazon CloudFront CreateCachePolicy API operation.

Syntax

New-CFCachePolicy
-CachePolicyConfig_Comment <String>
-CookiesConfig_CookieBehavior <CachePolicyCookieBehavior>
-CachePolicyConfig_DefaultTTL <Int64>
-ParametersInCacheKeyAndForwardedToOrigin_EnableAcceptEncodingBrotli <Boolean>
-ParametersInCacheKeyAndForwardedToOrigin_EnableAcceptEncodingGzip <Boolean>
-HeadersConfig_HeaderBehavior <CachePolicyHeaderBehavior>
-Cookies_Item <String[]>
-Headers_Item <String[]>
-QueryStrings_Item <String[]>
-CachePolicyConfig_MaxTTL <Int64>
-CachePolicyConfig_MinTTL <Int64>
-CachePolicyConfig_Name <String>
-Cookies_Quantity <Int32>
-Headers_Quantity <Int32>
-QueryStrings_Quantity <Int32>
-QueryStringsConfig_QueryStringBehavior <CachePolicyQueryStringBehavior>
-Select <String>
-Force <SwitchParameter>

Description

Creates a cache policy. After you create a cache policy, you can attach it to one or more cache behaviors. When it’s attached to a cache behavior, the cache policy determines the following:
  • The values that CloudFront includes in the cache key. These values can include HTTP headers, cookies, and URL query strings. CloudFront uses the cache key to find an object in its cache that it can return to the viewer.
  • The default, minimum, and maximum time to live (TTL) values that you want objects to stay in the CloudFront cache.
The headers, cookies, and query strings that are included in the cache key are automatically included in requests that CloudFront sends to the origin. CloudFront sends a request when it can’t find an object in its cache that matches the request’s cache key. If you want to send values to the origin but not include them in the cache key, use OriginRequestPolicy. For more information about cache policies, see Controlling the cache key in the Amazon CloudFront Developer Guide.

Parameters

-CachePolicyConfig_Comment <String>
A comment to describe the cache policy. The comment cannot be longer than 128 characters.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-CachePolicyConfig_DefaultTTL <Int64>
The default amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. CloudFront uses this value as the object’s time to live (TTL) only when the origin does not send Cache-Control or Expires headers with the object. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.The default value for this field is 86400 seconds (one day). If the value of MinTTL is more than 86400 seconds, then the default value for this field is the same as the value of MinTTL.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-CachePolicyConfig_MaxTTL <Int64>
The maximum amount of time, in seconds, that objects stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. CloudFront uses this value only when the origin sends Cache-Control or Expires headers with the object. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.The default value for this field is 31536000 seconds (one year). If the value of MinTTL or DefaultTTL is more than 31536000 seconds, then the default value for this field is the same as the value of DefaultTTL.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-CachePolicyConfig_MinTTL <Int64>
The minimum amount of time, in seconds, that you want objects to stay in the CloudFront cache before CloudFront sends another request to the origin to see if the object has been updated. For more information, see Managing How Long Content Stays in an Edge Cache (Expiration) in the Amazon CloudFront Developer Guide.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-CachePolicyConfig_Name <String>
A unique name to identify the cache policy.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-Cookies_Item <String[]>
A list of cookie names.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_CookiesConfig_Cookies_Items
-Cookies_Quantity <Int32>
The number of cookie names in the Items list.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_CookiesConfig_Cookies_Quantity
-CookiesConfig_CookieBehavior <CachePolicyCookieBehavior>
Determines whether any cookies in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values are:
  • none – Cookies in viewer requests are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin. Even when this field is set to none, any cookies that are listed in an OriginRequestPolicyare included in origin requests.
  • whitelist – The cookies in viewer requests that are listed in the CookieNames type are included in the cache key and automatically included in requests that CloudFront sends to the origin.
  • allExcept – All cookies in viewer requests that are not listed in the CookieNames type are included in the cache key and automatically included in requests that CloudFront sends to the origin.
  • all – All cookies in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_CookiesConfig_CookieBehavior
This parameter overrides confirmation prompts to force the cmdlet to continue its operation. This parameter should always be used with caution.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-Headers_Item <String[]>
A list of HTTP header names.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_HeadersConfig_Headers_Items
-Headers_Quantity <Int32>
The number of header names in the Items list.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_HeadersConfig_Headers_Quantity
-HeadersConfig_HeaderBehavior <CachePolicyHeaderBehavior>
Determines whether any HTTP headers are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values are:
  • none – HTTP headers are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin. Even when this field is set to none, any headers that are listed in an OriginRequestPolicyare included in origin requests.
  • whitelist – The HTTP headers that are listed in the Headers type are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_HeadersConfig_HeaderBehavior
-ParametersInCacheKeyAndForwardedToOrigin_EnableAcceptEncodingBrotli <Boolean>
A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin.This field is related to the EnableAcceptEncodingGzip field. If one or both of these fields is trueand the viewer request includes the Accept-Encoding header, then CloudFront does the following:
  • Normalizes the value of the viewer’s Accept-Encoding header
  • Includes the normalized header in the cache key
  • Includes the normalized header in the request to the origin, if a request is necessary
For more information, see Compression support in the Amazon CloudFront Developer Guide.If you set this value to true, and this cache behavior also has an origin request policy attached, do not include the Accept-Encoding header in the origin request policy. CloudFront always includes the Accept-Encoding header in origin requests when the value of this field is true, so including this header in an origin request policy has no effect.If both of these fields are false, then CloudFront treats the Accept-Encoding header the same as any other HTTP header in the viewer request. By default, it’s not included in the cache key and it’s not included in origin requests. In this case, you can manually add Accept-Encoding to the headers whitelist like any other HTTP header.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_EnableAcceptEncodingBrotli
-ParametersInCacheKeyAndForwardedToOrigin_EnableAcceptEncodingGzip <Boolean>
A flag that can affect whether the Accept-Encoding HTTP header is included in the cache key and included in requests that CloudFront sends to the origin.This field is related to the EnableAcceptEncodingBrotli field. If one or both of these fields is trueand the viewer request includes the Accept-Encoding header, then CloudFront does the following:
  • Normalizes the value of the viewer’s Accept-Encoding header
  • Includes the normalized header in the cache key
  • Includes the normalized header in the request to the origin, if a request is necessary
For more information, see Compression support in the Amazon CloudFront Developer Guide.If you set this value to true, and this cache behavior also has an origin request policy attached, do not include the Accept-Encoding header in the origin request policy. CloudFront always includes the Accept-Encoding header in origin requests when the value of this field is true, so including this header in an origin request policy has no effect.If both of these fields are false, then CloudFront treats the Accept-Encoding header the same as any other HTTP header in the viewer request. By default, it’s not included in the cache key and it’s not included in origin requests. In this case, you can manually add Accept-Encoding to the headers whitelist like any other HTTP header.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_EnableAcceptEncodingGzip
-QueryStrings_Item <String[]>
A list of query string names.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_QueryStringsConfig_QueryStrings_Items
-QueryStrings_Quantity <Int32>
The number of query string names in the Items list.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_QueryStringsConfig_QueryStrings_Quantity
-QueryStringsConfig_QueryStringBehavior <CachePolicyQueryStringBehavior>
Determines whether any URL query strings in viewer requests are included in the cache key and automatically included in requests that CloudFront sends to the origin. Valid values are:
  • none – Query strings in viewer requests are not included in the cache key and are not automatically included in requests that CloudFront sends to the origin. Even when this field is set to none, any query strings that are listed in an OriginRequestPolicyare included in origin requests.
  • whitelist – The query strings in viewer requests that are listed in the QueryStringNames type are included in the cache key and automatically included in requests that CloudFront sends to the origin.
  • allExcept – All query strings in viewer requests that are not listed in the QueryStringNames type are included in the cache key and automatically included in requests that CloudFront sends to the origin.
  • all – All query strings in viewer requests are included in the cache key and are automatically included in requests that CloudFront sends to the origin.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesCachePolicyConfig_ParametersInCacheKeyAndForwardedToOrigin_QueryStringsConfig_QueryStringBehavior
-Select <String>
Use the -Select parameter to control the cmdlet output. The default value is '*'. Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.CloudFront.Model.CreateCachePolicyResponse). Specifying the name of a property of type Amazon.CloudFront.Model.CreateCachePolicyResponse will result in that property being returned. Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAK
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-EndpointUrl <String>
The endpoint to make the call against.Note: This parameter is primarily for internal AWS use and is not required/should not be specified for normal usage. The cmdlets normally determine which endpoint to call based on the region specified to the -Region parameter or set as default in the shell (via Set-DefaultAWSRegion). Only specify this parameter if you must direct the call to a specific custom endpoint.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-ProfileLocation <String>
Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials.If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesStoredCredentials, AWSProfileName
-Region <Object>
The system name of an AWS region or an AWSRegion instance. This governs the endpoint that will be used when calling service operations. Note that the AWS resources referenced in a call are usually region-specific.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesRegionToCall
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSK, SecretAccessKey
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesST

Outputs

This cmdlet returns an Amazon.CloudFront.Model.CreateCachePolicyResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack.

Supported Version

AWS Tools for PowerShell: 2.x.y.z