How to enable Keep Alive connection in AWS S3 or CloudFront? - amazon-s3

How to enable Keep Alive connection in AWS S3 or CloudFront? I uploaded images to S3 and found that the urls don't have keep alive connection. They cannot be cached by client application even I added cache-control headers to each image file.

From the tag wiki for Keep-Alive:
A feature of HTTP where the same connection is used for multiple
requests, speeding up downloading of web pages with multiple
resources.
I'm not aware of any relation that this has to cache behavior. I usually see mentions of Keep-Alive headers in relation to long-polling, which wouldn't make any sense to enable on S3.
I think you are incorrectly linking keep-alive headers with your browser's ability to cache static content. The cache-control headers should be all that is needed for caching of static content in the browser.
Are you verifying that the response from CloudFront includes the cache-control headers you have set on the S3 objects? Perhaps you need to invalidate the CloudFront cache after you updated the headers.

Related to your question I think the problem is in setting correct TTL(>0) to your origin/behaviours in Cloudfront.
Also AWS Cloudfront (from 30 March 2017) enables you to set up custom read and keep-alive timeouts for custom origins.

Related

How do I prevent CloudFront & browser from caching files

I have a Vue.js app which is deployed on CloudFront + s3. I see that part of the clients receive an older version of the app, and I don׳t know how to decide if the issue is in the browser or in Cloudfront.
What have I done already?
Cloudfront - After every deployment I run invalidations.
Broswer - I tried to set 'Cache-Control' response header in S3 on index.html to 'no-cache, no-store, must-revalidate' and also to 'max-age=0'.
Unfortunately, Both of the solutions did not work.
Do you have a suggestion for more solutions that I can check?

Cloudfront Won't Set Expiration Header from S3 Origin

I am using an S3 bucket to store a bunch of product images for a large web site. These images are being served through Cloudfront with the S3 bucket as the origin. I have noticed that Cloudfront does not put an expiration header on the image even though I have set the distribution behavior to customize the cache headers and set a long min, max, and default TTL in Cloudfront.
I understand that I can put an expiration on the S3 object, however this is going to be quite impractical as I have millions of images. I was hoping that cloudfront would do me the honors of adding this header for me, but it does not.
So my question is the only way to get this expiration header to apply it every S3 object, or perhaps I am missing something in Cloudfront that will do it for me?
CloudFront's TTL configuration only controls the amount of time CloudFront keeps the object in the cache.
It doesn't add any headers.
So, yes, you'll need to set these on the objects in S3.
Note that Cache-Control: is usually considered a better choice than Expires:.
A alternative to avoid updating the onjects is to configure a proxy server in EC2 in the same region as the bucket, and let the server add the headers as the responses pass through it.
Request: CloudFront >> Proxy >> S3
Response: S3 >> Proxy >> CloudFront
...for what it's worth.

Is it possible to enable CORS on AWS CloudFront without S3?

I'm using CloudFront CDN to simply cache my static contents in "Origin Pull" mode. The CloudFront origin is my website.
However I've encountered a CORS problem. My browser doesn't let my web pages load my fonts files from CloudFront ... The ironic thing about it is that those fonts were fetched and cached from my website in the first place :(
After googling this matter a bit, I noticed that all blogs/tutorials explain how to enable CORS on an S3 bucket used as the origin for CloudFront, and letting CloudFront forward the Access-Control-Allow-XXX headers from S3 to the client.
I don't need an S3 bucket and would like to keep it that way for the sake of simplicity, if possible.
Is it possible to enable CORS on CloudFront ? Even a quick and dirty solution, such as setting the access control header on all responses would be good enough.
Or what other alternatives do I have on CloudFront ? If the easiest other alternative is indeed to use an S3 bucket, what are the drawbacks (modifications to do on my website, service performance, and cost) ?

Browser ignore Cache-Control

I set a static file on Amazon S3 to use Cache-Control: max-age: 259200, must-revalidate. However, when I load a test page on my browser in Safari, the resource tracker shows it's getting the file from Amazon S3 even though it's supposed to be cached. What's going on? Do browsers have special caching rules I'm not aware of that override Cache-Control?

Removing response headers when accessing images from S3

Can we remove response headers when we are accessing images stored on Amazon S3?
By default it is giving the following headers:
x-amz-id-2:
x-amz-request-id:
Server:
By default it is giving amazon related values for these headers. Is there any way to remove headers?
Not without proxying the requests through some software you control that can strip the headers. Pretty sure Amazon has no user setting for that.