Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Cache for CloudFront

I am using my own domain to serve HTTPS s3 bucket via CloudFront. I don't want it to cache since its for QA environment.

I'm wondering how could i achieve this. Is it by Using Origin Cache Headers or Customize with 0 Time To Live?

like image 571
JamZ Avatar asked Nov 20 '17 11:11

JamZ


People also ask

How do I turn off CloudFront caching?

On your custom origin web server application, add Cache-Control no-cache, no-store, or private directives to the objects that you don't want CloudFront to cache. Or, add Expires directives to the objects that you don't want CloudFront to cache.

Does CloudFront cache content?

CloudFront caches your objects based on the values in all of the specified headers. CloudFront also forwards the headers that it forwards by default, but it caches your objects based only on the headers that you specify. Forward only the default headers.

What is cache policy in CloudFront?

CloudFront provides a set of managed cache policies that you can attach to any of your distribution's cache behaviors. With a managed cache policy, you don't need to write or maintain your own cache policy. The managed policies use settings that are optimized for specific use cases.

Does CloudFront do caching?

One of the purposes of using CloudFront is to reduce the number of requests that your origin server must respond to directly. With CloudFront caching, more objects are served from CloudFront edge locations, which are closer to your users. This reduces the load on your origin server and reduces latency.


1 Answers

Please use customize option (Behavior -> Cache Behavior Settings) in AWS management console (CloudFront) and input the value for Minimum TTL, Default TTL, and Maximum TTL accordingly.

Minimum TTL

Specify the minimum amount of time, in seconds, that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The default value for Minimum TTL is 0 seconds.

Maximum TTL

Specify the maximum amount of time, in seconds, that you want objects to stay in CloudFront caches before CloudFront queries your origin to see whether the object has been updated. The value that you specify for Maximum TTL applies only when your origin adds HTTP headers such as Cache-Control max-age, Cache-Control s-maxage, or Expires to objects.

Default TTL

Specify the default amount of time, in seconds, that you want objects to stay in CloudFront caches before CloudFront forwards another request to your origin to determine whether the object has been updated. The value that you specify for Default TTL applies only when your origin does not add HTTP headers such as Cache-Control max-age, Cache-Control s-maxage, or Expires to objects.

like image 146
notionquest Avatar answered Sep 24 '22 03:09

notionquest