Diagnosing my Slow Netlify Deploy Times
For some time, my site has been getting slower and slower to deploy. It's definitely become more apparent now I'm publishing more content via my Micropub endpoint, as well as storing more content in the site itself.
For context, Netlify deployments currently take ~7-10 minutes, and recently have been incredibly flaky with probably 70% of them failing to deploy and needing to be restarted.
Tonight I had a chance to look into it, wondering if it was an issue with the version of the Netlify command-line I'm using.
After some further investigation, I found that the netlify
was performing exactly the same upload as netlifyctl
.
As I thought I'd ruled out the build tooling, I decided to look at difference between my live site and my local site.
What I found next was very interesting:
- © <time datetime="2019-10-06 23:06:16.213737433 +0100 BST m=+0.974757224">2019</time> Jamie Tanna.
+ © <time datetime="2019-10-06 22:22:16.213737433 +0100 BST m=+0.974757224">2019</time> Jamie Tanna.
Notice that the <time>
element has a full datetime of the current instant, but to the user we just want to show the copyright year. This level of precision isn't required as all I want to be showing is the year, as there are various other metrics for finding out the year of the copyright for a given piece of content on my site.
Because this line is different, every file including this line is going to be different to the copy in Netlify's CDN, so Netlify rightly says, "upload this!".
With this line removed, I've now cut the deploy time to ~2 minutes, and instead of uploading ~2200 files, it's now only updating 137! That's a huge saving, and all I needed to do was think more carefully around what needs to change in a file and what doesn't - who knew!