Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save minchao/d36e2ed92e99b4e969815c230eb8c18c to your computer and use it in GitHub Desktop.

Select an option

Save minchao/d36e2ed92e99b4e969815c230eb8c18c to your computer and use it in GitHub Desktop.
cloudformation-example-cloudfront-no-cache
Resources:
NoCachePolicy:
Type: AWS::CloudFront::CachePolicy
Properties:
CachePolicyConfig:
DefaultTTL: 0
MaxTTL: 300
MinTTL: 0
ParametersInCacheKeyAndForwardedToOrigin:
CookiesConfig:
CookieBehavior: all
EnableAcceptEncodingBrotli: true
EnableAcceptEncodingGzip: true
HeadersConfig:
HeaderBehavior: whitelist
Headers:
- User-Agent
QueryStringsConfig:
QueryStringBehavior: all
Distribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
CacheBehaviors:
- AllowedMethods:
- GET
- HEAD
- OPTIONS
- PUT
- PATCH
- POST
- DELETE
CachePolicyId:
Ref: NoCachePolicy
Compress: true
PathPattern: /api/*
TargetOriginId: CloudFrontDistributionOrigin
ViewerProtocolPolicy: https-only
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6
Compress: true
TargetOriginId: CloudFrontDistributionOrigin
ViewerProtocolPolicy: https-only
Origins:
- CustomOriginConfig:
HTTPPort: 80
OriginProtocolPolicy: http-only
Id: CloudFrontDistributionOrigin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment