{"id":38707,"date":"2020-03-26T12:12:33","date_gmt":"2020-03-26T19:12:33","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/premier-developer\/?p=38707"},"modified":"2020-03-18T12:20:52","modified_gmt":"2020-03-18T19:20:52","slug":"improving-angular-ci-build-time-using-azure-devops-cache-task","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/premier-developer\/improving-angular-ci-build-time-using-azure-devops-cache-task\/","title":{"rendered":"Improving Angular CI Build Time Using Azure DevOps \u201cCache Task\u201d"},"content":{"rendered":"<p>Sr. Consultant <a href=\"https:\/\/www.linkedin.com\/in\/waelkdouh\/\" target=\"_blank\" rel=\"noopener noreferrer\">Wael Kdouh<\/a> explores how to optimize build time using Azure DevOps Cache Tasks.<\/p>\n<hr \/>\n<p>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.<\/p>\n<p>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 <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/devops\/pipelines\/release\/caching?view=azure-devops\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">cache task<\/a>. This task works like any other task and is added to the <em>steps <\/em>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 \u201csave cache\u201d step is run for each \u201crestore cache\u201d step that was not skipped. This step is responsible for saving the cache.<\/p>\n<p><a href=\"https:\/\/medium.com\/@waelkdouh\/improving-angular-ci-build-time-using-azure-devops-cache-task-ec059a45dd5d\">Continue reading on Wael&#8217;s blog<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As demonstrated above I was able to drop the build time from 5m 10s to 2m 34s which is roughly a 50% reduction in build time. This is a significant saving especially when you factor in the fact that you will run the build several times a day. This can quickly add up to hours of saved build time each day.<\/p>\n","protected":false},"author":582,"featured_media":38708,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[22],"tags":[2571,9222,3],"class_list":["post-38707","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-azure-devops","tag-cache-tasks","tag-team"],"acf":[],"blog_post_summary":"<p>As demonstrated above I was able to drop the build time from 5m 10s to 2m 34s which is roughly a 50% reduction in build time. This is a significant saving especially when you factor in the fact that you will run the build several times a day. This can quickly add up to hours of saved build time each day.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/38707","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/users\/582"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/comments?post=38707"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/posts\/38707\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media\/38708"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/media?parent=38707"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/categories?post=38707"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/premier-developer\/wp-json\/wp\/v2\/tags?post=38707"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}