Search code examples
amazon-cloudfront

AWS Cloudfront only cache objects for only certain POST requests


Can we use AWS Cloudfront and only cache the response for only certain requests

ie we only want to cache requests in Cloudfront for urls such as

POST https://server.com/?q="sometext"

Thanks


Solution

  • CloudFront can only cache the responses to request methods GET and HEAD (and, optionally, OPTIONS).

    CloudFront does not cache responses to requests that use other methods.

    If your ?q=... request is something idempotent, like a search query, consider using GET instead of POST, using <form method="get" ...> for example, if it's coming from a form.