aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Bring Back cacheControl as Storage Option in v6 #13581

Open chris-xylem opened 3 months ago

chris-xylem commented 3 months ago

Is this related to a new or existing framework?

Angular

Is this related to a new or existing API?

Storage

Is this related to another service?

S3

Describe the feature you'd like to request

In AWS Amplify v5 we were able to pass cacheControl: 'no-cache' as an option to ensure we were downloading the most recent S3 object; that is no longer the case in v6 😞 .

The documentation is also conflicting it reports the following:

downloadData is cached; if you have recently modified a file you may not get the latest version right away. You can pass in cacheControl: 'no-cache' to get the latest version.

https://docs.amplify.aws/gen1/angular/build-a-backend/storage/download/#frequently-asked-questions

But then in the migration steps reports:

cacheControl: This option has been removed and now defers to the HTTP caching behavior configured by the runtime.

https://docs.amplify.aws/gen1/angular/build-a-backend/storage/storage-v5-to-v6-migration-guide/

Not sure why this option was removed as we used it with our applications to ensure users were getting the most recent files from S3.

I feel as if this should be a feature that is added back in or provide a alternative to ensure we can get the most recent files from S3 when using AWS Amplify v6.

Describe the solution you'd like

AWS Amplify v6 users should be able to specify if they want a file to come or not come from cache like the feature that was enabled in v5.

Describe alternatives you've considered

I don't have an alternative unless the AWS Amplify team does.

Additional context

No response

Is this something that you'd be interested in working on?

cwomack commented 3 months ago

Helllo, @chris-xylem 👋 and thank you for opening this issue. There appears to be an error in the bullet points within the FAQ's on this page as you've pointed out. The cacheControl option was indeed removed in v6 as called out in the migration guide that you linked above.

I'll create a docs issue for this to get the error corrected, but this option was removed intentionally in v6 to allow for the caching behavior to be primarily determined by the services and configurations involved in hosting and delivering your application.

VadimDubovoy commented 3 months ago

Hello @cwomack, and thank you for the response on the issue. But the main question is how should we make a request that will be guaranteed to return the most recent version of the file. It's unbelievable that this option was intentionally removed without any alternative provided.

jovan-kecojevic commented 2 months ago

@cwomack I am also facing difficulties with these changes as I want to always fetch the most recent version in my case, and the cacheControl: 'no-cache' did a great job for me. So I would really be interested in using something like this in the future.

One workaround that we've figured out is to enable versioning on the S3 bucket where the files are stored. Somehow that helps the method to fetch the most recent version of the file.

websinv commented 2 weeks ago

Hello - is there any update on this? We are building a website that has regulatory implications and users must be able to get the latest version of an S3 file