| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
For HTTP and HTTPS download distributions, you can choose whether you want CloudFront to forward cookies to your origin. For RTMP streaming distributions, you cannot configure CloudFront to process cookies.
Important
Amazon S3 and some HTTP servers do not process cookies. Do not configure CloudFront cache behaviors to forward cookies to an origin that doesn't process cookies, or you'll adversely affect cacheability and, therefore, performance.
For download distributions, you can choose whether you want CloudFront to forward cookies to your origin and, if so, you can choose whether you want CloudFront to forward all cookies or only the cookies that you specify. If you choose to forward only the cookies that you specify, you can specify up to 10 cookies for each cache behavior in your distribution. To request an increase in the default limit of 10 cookies per cache behavior, go to http://aws.amazon.com/cloudfront-request/.
When you configure CloudFront to forward cookies to your origin:
CloudFront includes cookie name-value pairs, but not cookie attributes (for example, path or
expiration time), when it forwards requests to your origin. For example, in the following Cookie
header, CloudFront forwards the cookie name-value pair country=ata but does not forward the cookie
attribute $Path=/:
Cookie: country=ata; $Path=/;
If you configure CloudFront to forward only a specified list of cookies, CloudFront removes any cookies not on that list before forwarding the request to your origin.
If-Modified-Since and If-None-Match conditional requests
are not supported.
CloudFront sorts the cookies in natural order by cookie name before forwarding the request to your origin.
When your origin returns cookies to CloudFront:
If you configure CloudFront to forward all cookies to your origin for a given cache behavior, CloudFront caches the response and all cookies and cookie attributes that are returned by your origin. CloudFront also returns the object and all cookies and cookie attributes to the viewer.
If you configure CloudFront to forward only specified cookies to your origin for a given cache behavior, CloudFront caches the response, the specified cookies, and the associated cookie attributes. CloudFront also returns the object, including only the specified cookies and cookie attributes, to the viewer.
If you do not want CloudFront to cache cookies and cookie attributes, configure your origin server to add the following header in responses to CloudFront:
no-cache="Set-Cookie"
If you configure CloudFront to forward cookies to your origin, CloudFront uses the cookies that the viewer includes in the request
to uniquely identify an object in the cache. For example, if three requests for the object /images/image1.jpg
contain three different name-value pairs, CloudFront will cache the same object three times, once for each name-value pair.
This is true even if your origin ignores the cookie values in the request and always returns the same image1.jpg
object to CloudFront. As a result, CloudFront forwards more requests to your origin server for the same object, which slows performance
and increases the load on your origin server. If your origin server does not vary its response based on the value of a
given cookie, we recommend that you not configure CloudFront to forward that cookie to your origin.
Cookie names and values are both case sensitive. For example, if two cookies for the same object are identical except for case, CloudFront will cache the object twice.
If you configure CloudFront to log requests and to log cookies, CloudFront logs all cookies and all cookie attributes even if you configure CloudFront not to forward cookies to your origin or you configure CloudFront to forward only a specified list of cookies. For more information about CloudFront logging, see Access Logs.
For information about using the CloudFront console to update a distribution so CloudFront forwards cookies to the origin, see Listing, Viewing, and Updating CloudFront Distributions. For information about using the CloudFront API to update a distribution, go to PUT Distribution Config in the Amazon CloudFront API Reference.
For streaming distributions, when CloudFront requests an object from the origin server, it removes any cookies before forwarding the request to your origin. If your origin returns any cookies along with the object, CloudFront removes them before returning the object to the viewer. For streaming distributions, CloudFront does not cache cookies in edge caches.
You cannot configure CloudFront to log cookies for streaming distributions.