Improving Angular CI Build Time Using Azure DevOps “Cache Task”

Developer Support

Sr. Consultant Wael Kdouh explores how to optimize build time using Azure DevOps Cache Tasks.

In an era where Continuous Integration/Continuous Deployment (CI/CD) is the norm, improving build times becomes a necessity for a successful DevOps strategy. One of the essential factors that lead to improved build times is eliminating the waste. When building an Angular application this means avoiding downloading the same npm packages after each build. Not only is it a time consuming process but it also introduces several unnecessary API calls.

This problem historically existed when using hosted build agents since each time a build is triggered a new VM is allocated and thus any previously cached npm packages are lost. One way to get around this is to use a self-hosted build agent. Whereas this is an effective technique it may not always be a feasible solution. Fortunately, Azure DevOps now offers a new build task called cache task. This task works like any other task and is added to the steps section of a job. When a cache step is encountered during a run, the task will restore the cache based on the provided inputs. If no cache is found, the step completes and the next step in the job is run. After all steps in the job have run and assuming a successful job status, a special “save cache” step is run for each “restore cache” step that was not skipped. This step is responsible for saving the cache.

Continue reading on Wael’s blog


Discussion is closed.

Feedback usabilla icon