aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
461 stars 116 forks source link

On demand Cloudfront Cache Invalidation #3967

Open antonioMerkulov opened 1 week ago

antonioMerkulov commented 1 week ago

Before opening, please confirm:

Amplify Hosting feature

Build settings, Frontend builds

Is your feature request related to a problem? Please describe:

In an AWS Amplify Generation 2 environment, Amplify uses CloudFront under the hood for content delivery. There is an option within Amplify called "Keep cookies in cache key" which the development team has disabled.

The primary reason for disabling this option is that on every page load, cookies like Google Tag Manager (GTM) and Datadog generate different values. Including these cookies in the cache key would prevent effective caching, as CloudFront would treat each unique cookie value as a separate cache entry.

When a new build is generated in Amplify, CloudFront's cache is automatically invalidated, ensuring that users receive the most recent content. However, when content is updated within the Content Management System (CMS), there is no mechanism to invalidate the CloudFront cache without running a new build. This limitation exists because Amplify Generation 2 does not provide direct access to the underlying CloudFront distribution, making it impossible to programmatically invalidate the cache in response to CMS changes.

Describe how you'd like this feature to work

Is it possible within AWS Amplify Generation 2 to specify specific cookie names to include in the CloudFront cache key, similar to native CloudFront configurations?

Are there alternative methods to invalidate the CloudFront cache upon CMS content changes without initiating a new build?

What best practices can be employed to manage cache invalidation in this scenario to balance performance and content freshness?

github-actions[bot] commented 1 week ago

This has been identified as a feature request. If this feature is important to you, we strongly encourage you to give a 👍 reaction on the request. This helps us prioritize new features most important to you. Thank you!

jagmitg commented 1 week ago

i would very interested and keen on this! Really dont want to deploy every single time we make any content change.

assajak commented 1 week ago

I have the same problem, content was updated but i have to wait time to see result.