When and how to leverage caching or artifacts
With GitLab, there is often confusion about the usage of caching or artifacts. Many users are curious as to which functionality to leverage and when. We aim to demystify both in this chapter and give you the tools to implement either approach while explaining the benefits and pitfalls of each pattern.
Caching should be thought of as a method to save items that are commonly used in CI jobs or stages. It shouldn’t be thought of as a means to pass items between stages or jobs – that’s what artifacts are for. The difference is important because of the implementation and configuration of each. A cache is not built or designed to be a method to move items between CI jobs. Because of this, in the future, any features or changes that are made to it will be tailored toward that functionality.
Artifacts are the main way to support storing items created by your CI job indefinitely, as well as passing them as a dependency...