I am looking for a way to get the client to stop caching a file but always request it from CloudFront. The search always yields stuff related to clearing cache at CloudFront.
In my case, I have a CF distribution pointing to my app. Whenever I want to clear something out of CloudFront, I use an invalidation request. So the caching behavior between origin and CF is under control. However, I want to force the browsers to stop keeping a cache of any kind for the resource. If I return a cache header from my origin, it looks like it's going to alter the caching behavior between CF and Origin.
How can I have different caching behavior between client and CF?
Do you have control over when the file is requested? What is the use case?
If you want to disable caching altogether, simply set the appropriate headers in origin. If you want to cache origin in Cloudfront, but not in the client, you can modify the headers in Cloudfront using Lambda@Edge.
If it is an asset that you are serving as a part of your own website, e.g. a javascript file, then you can simply add a unique hash to the filename. Instead of serving app.js, you serve app-52638308.js, and the number changes when you update the file. The files themselves are always cached, and don't need to be invalidated.