Method: Aws::CloudFront::Types::CacheBehavior#viewer_protocol_policy

Defined in:
lib/aws-sdk-cloudfront/types.rb

#viewer_protocol_policyString

The protocol that viewers can use to access the files in the origin specified by ‘TargetOriginId` when a request matches the path pattern in `PathPattern`. You can specify the following options:

  • ‘allow-all`: Viewers can use HTTP or HTTPS.

  • ‘redirect-to-https`: If a viewer submits an HTTP request, CloudFront returns an HTTP status code of 301 (Moved Permanently) to the viewer along with the HTTPS URL. The viewer then resubmits the request using the new URL.

  • ‘https-only`: If a viewer sends an HTTP request, CloudFront returns an HTTP status code of 403 (Forbidden).

For more information about requiring the HTTPS protocol, see

Requiring HTTPS Between Viewers and CloudFront][1

in the *Amazon

CloudFront Developer Guide*.

<note markdown=“1”> The only way to guarantee that viewers retrieve an object that was fetched from the origin using HTTPS is never to use any other protocol to fetch the object. If you have recently changed from HTTP to HTTPS, we recommend that you clear your objects’ cache because cached objects are protocol agnostic. That means that an edge location will return an object from the cache regardless of whether the current request protocol matches the protocol used previously. For more information, see [Managing Cache Expiration] in the *Amazon CloudFront Developer Guide*.

</note>

[1]: docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-https-viewers-to-cloudfront.html [2]: docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html

Returns:

  • (String)


889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
# File 'lib/aws-sdk-cloudfront/types.rb', line 889

class CacheBehavior < Struct.new(
  :path_pattern,
  :target_origin_id,
  :trusted_signers,
  :trusted_key_groups,
  :viewer_protocol_policy,
  :allowed_methods,
  :smooth_streaming,
  :compress,
  :lambda_function_associations,
  :function_associations,
  :field_level_encryption_id,
  :realtime_log_config_arn,
  :cache_policy_id,
  :origin_request_policy_id,
  :response_headers_policy_id,
  :grpc_config,
  :forwarded_values,
  :min_ttl,
  :default_ttl,
  :max_ttl)
  SENSITIVE = []
  include Aws::Structure
end