Managing the cache configuration for an app - AWS Amplify Hosting

Managing the cache configuration for an app

Amplify uses Amazon CloudFront to manage the caching configuration for your hosted applications. A cache configuration is applied to each app to optimize for the best performance.

On August 13, 2024, Amplify released improvements to caching efficiency for applications. For more information, see CDN Caching Improvements for Better App Performance with AWS Amplify Hosting.

The following table summarizes Amplify support for specific caching behaviors before and after the caching improvements release.

Caching behavior Previous support With caching improvements

You can add custom headers for an app in the Amplify console or in a customHeaders.yaml file. One of the headers that you can override is Cache-Control. For more information, see Custom headers.

Yes

Yes

Amplify respects the Cache-Control headers that you define in a customHeaders.yaml file and they take precedence over Amplify's default cache settings.

Yes Yes

Amplify respects the Cache-Control headers set within an application’s framework for dynamic routes (for example, Next.js SSR routes). If a Cache-Control header is set in the app's customHeaders.yaml file, this takes precedence over settings in the next.config.js file.

Yes

Yes

Each new CI/CD app deployment clears the cache.

Yes

Yes

You can turn on performance mode for an app.

Yes

No

The performance mode setting is no longer available in the Amplify console. However, you can create a Cache-Control header that sets the s-maxage directive. For instructions, see Managing app performance.

The following table lists the changes to the default values for specific cache settings.

Cache setting Previous default value Default value with caching improvements

Cache duration for static assets

Two seconds

One year

Cache duration for reverse proxy responses

Two seconds

Zero seconds (no caching)

Max Time to Live (TTL)

Ten minutes

One year

For more information about how Amplify determines the caching configuration to apply to an application and instructions on managing cache key configuration, see the following topics.