How can I cache dependencies (like `node_modules`) in my GitHub Actions workflow to speed up Cloudflare Worker deployments?

Responsive Ad Header

Question

Grade: Education Subject: Support
How can I cache dependencies (like `node_modules`) in my GitHub Actions workflow to speed up Cloudflare Worker deployments?
Asked by:
123 Viewed 123 Answers

Answer (123)

Best Answer
(365)
Use the `actions/cache` action to cache your `node_modules` directory. This will significantly reduce the time it takes to install dependencies on subsequent workflow runs. Configure the cache key based on the `package-lock.json` or `yarn.lock` file to ensure the cache is invalidated when dependencies change. This speeds up deployments and reduces resource usage.