Search code examples
aws-amplify

What is the Cache Artifact in AWS Amplify's build process?


When using AWS Amplify to build a React project, there is a point in the build process in which a cache artifact is created. What is this?

I have a problem where this can grow to multiple gigabytes in size, and cause the build process to time out. For example, a 1 minute local build can take 30 minutes in amplify, and almost the entire time is spent on the Creating cache artifact step.

Here is a snippet of the Amplify build log:

2019-10-18T17:51:29.865Z [INFO]: ## Build completed successfully
2019-10-18T17:51:29.867Z [INFO]: # Starting caching...
2019-10-18T17:51:29.968Z [INFO]: Creating cache artifact...
2019-10-18T17:52:10.152Z [INFO]: # Cache artifact is: 318MB
2019-10-18T17:52:10.265Z [INFO]: # Uploading cache artifact...
2019-10-18T17:52:13.617Z [INFO]: # Caching completed

Solution

  • It's file cache that you might have configured. The files are saved to improve the build time, because it's not necessary go to the source file each time. For exemple, caching node_modules:

    This is configured in amplify.yml.

    version: 0.1
    backend:
      ...
    frontend:
      ...
      cache:
        paths:
          - node_modules/**/*