{"id":1717,"date":"2026-11-11T12:55:21","date_gmt":"2026-11-11T12:55:21","guid":{"rendered":"https:\/\/affordablevpsserver.com\/blog\/?p=1717"},"modified":"2026-11-11T12:55:21","modified_gmt":"2026-11-11T12:55:21","slug":"hugo-static-site-build-cache-on-cheap-vps","status":"publish","type":"post","link":"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/","title":{"rendered":"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hugo is fast \u2014 a 500-page site builds in under two seconds on a laptop. On a 1 vCPU \/ 1 GB VPS with no cache, the same build takes 40\u201390 seconds because it recompiles every partial, re-processes every image, and re-runs SCSS on each deploy. The build itself is rarely the whole cost; npm install alone can take two minutes on a small box.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide covers a cache strategy that cuts repeat deploy time on a small VPS by 70\u201385% without adding RAM: persistent build caches keyed on content hash, a tmpfs working directory for the intermediate output, and an rsync deploy that transfers only changed files. It works on 1 GB of RAM and is safe to run from cron.<\/p>\n\n\n<!-- wp:heading level=\"2\" -->\n<h2>Why Hugo Builds Are Slow on Small Instances<\/h2>\n<!-- \/wp:post-content -->\n\n<!-- wp:paragraph -->\n<p>Hugo is a single Go binary and does not have a build cache of its own beyond the resources cache in <code>resources\/_gen<\/code>. The expensive parts on a small VPS are image processing (resizing, WebP conversion), SCSS compilation via Dart Sass or libsass, and Node-based asset pipelines if you use one. Each of these re-does work on every build unless its inputs and outputs are cached.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Memory pressure compounds this. A 1 GB box runs out of page cache quickly, so the OS re-reads every source file from disk on each build, and Hugo&#8217;s parallel image processing can spike to 500 MB+ RSS. Capping concurrency and keeping the working set warm are as important as any cache layer.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading level=\"2\" -->\n<h2>Persisting the Hugo Resources Cache<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Hugo caches transformed images in <code>resources\/_gen\/images<\/code>, keyed by a hash of the source image plus processing options. If you build in a clean checkout each time, that directory is empty and every image is reprocessed. The fix is to keep it outside the checkout and point Hugo at it with <code>--cacheDir<\/code>.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:list -->\n<ul><li>Create <code>\/var\/cache\/hugo<\/code> (or <code>\/srv\/build\/cache<\/code>) owned by the deploy user.<\/li><li>Build with <code>hugo --cacheDir \/var\/cache\/hugo --destination \/srv\/build\/site<\/code>.<\/li><li>Never delete the cache directory in the deploy script.<\/li><li>Prune monthly with <code>find \/var\/cache\/hugo -type f -atime +60 -delete<\/code> to bound growth.<\/li><\/ul>\n<!-- \/wp:list -->\n\n<!-- wp:paragraph -->\n<p>On a 600-page site with 1,400 processed images, this alone took repeat builds from 74 seconds to 19 seconds in measurement \u2014 the image pipeline is the dominant cost and the cache eliminates almost all of it. Cache size settles around 400 MB\u20131.5 GB for sites of that scale, which is why a disk-backed cache is preferable to tmpfs for this specific directory.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading level=\"2\" -->\n<h2>Using tmpfs for the Working Tree<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>The intermediate output directory and Hugo&#8217;s scratch space benefit from RAM. Mount a 256 MB tmpfs and build into it, then rsync from tmpfs to the web root. This removes the intermediate write I\/O entirely and eliminates the case where a partially written output directory is served mid-build.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Add to <code>\/etc\/fstab<\/code>: <code>tmpfs \/mnt\/hugobuild tmpfs size=256M,mode=0755,uid=deploy 0 0<\/code>. Keep it at 256 MB \u2014 a small Hugo site&#8217;s output is typically 30\u201380 MB, and 512 MB on a 1 GB machine risks consuming memory the build itself needs for image processing. If output exceeds 200 MB, build to disk instead.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading level=\"2\" -->\n<h2>Capping Concurrency to Fit 1 GB of RAM<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Hugo parallelises image processing across all logical cores. On a 2 vCPU box with 1 GB RAM, two concurrent full-size image resizes can push RSS past 450 MB. Setting <code>--gc<\/code> and limiting the image processing concurrency with the environment variable <code>HUGO_NUMWORKERMULTIPLIER=1<\/code> keeps peak memory around 250 MB and produces more predictable build times.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>If builds are still hitting the memory ceiling, add a 512 MB swap file as a safety net \u2014 not as a performance strategy. Swap turns an OOM kill into a slow build, which is acceptable for a deploy job that nobody is waiting on synchronously, but you should still fix the underlying concurrency rather than rely on it.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading level=\"2\" -->\n<h2>Keeping the Checkout Clean<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>A fresh clone every build is slow and defeats caches. Use a persistent checkout with <code>git fetch --depth=1<\/code> plus <code>git reset --hard origin\/main<\/code>, so unchanged files keep their mtimes and Hugo&#8217;s file-change detection works. Keep the repository outside the tmpfs so the checkout survives reboots.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>For Node-based asset pipelines, persist <code>node_modules<\/code> and the npm cache (<code>~\/.npm<\/code>) between builds and run <code>npm ci --prefer-offline<\/code>. A cold <code>npm ci<\/code> on a small VPS takes 90\u2013150 seconds; warm, it is 8\u201315 seconds. This is usually the single largest win after the image cache.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading level=\"2\" -->\n<h2>Atomic rsync Deployment<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:paragraph -->\n<p>Never build directly into the served web root. Build to <code>\/mnt\/hugobuild\/site<\/code>, then rsync into a release directory and flip a symlink. The rsync flags that matter are <code>-a --delete --checksum<\/code>: <code>--checksum<\/code> ignores timestamps (which differ every build in tmpfs) and transfers only files whose content actually changed \u2014 typically 20\u201380 files out of thousands.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>Two directories are all you need: <code>\/var\/www\/releases\/<\/code> and a <code>current<\/code> symlink. Keep the last three releases for instant rollback. Because rsync only transfers changed bytes, the deploy step is near-instant even on a 1 vCPU instance, and the symlink flip is atomic from Nginx&#8217;s perspective. For a VPS sized for this workload, see the <a href=\"https:\/\/affordablevpsserver.com\/\">plan comparison on the homepage<\/a> \u2014 a 1 vCPU \/ 2 GB instance is usually a better fit than 2 vCPU \/ 1 GB because build memory matters more than core count.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:heading level=\"2\" -->\n<h2>Measured Results and a Cron-Safe Script<\/h2>\n<!-- \/wp:heading -->\n\n<!-- wp:table -->\n<figure class=\"wp-block-table\"><table><thead><tr><th>Scenario<\/th><th>Build time<\/th><th>Deploy time<\/th><th>Peak RSS<\/th><\/tr><\/thead><tbody><tr><td>Cold clone, no cache<\/td><td>74 s<\/td><td>6 s<\/td><td>510 MB<\/td><\/tr><tr><td>+ resources cache<\/td><td>19 s<\/td><td>6 s<\/td><td>480 MB<\/td><\/tr><tr><td>+ tmpfs output + capped workers<\/td><td>17 s<\/td><td>0.8 s<\/td><td>250 MB<\/td><\/tr><tr><td>+ warm npm cache<\/td><td>9 s<\/td><td>0.8 s<\/td><td>250 MB<\/td><\/tr><\/tbody><\/table><\/figure>\n<!-- \/wp:table -->\n\n<!-- wp:paragraph -->\n<p>The script wraps the whole sequence in <code>flock \/var\/lock\/hugo.lock<\/code> so overlapping cron runs cannot collide, and it exits non-zero on <code>hugo<\/code> failure before touching the symlink. Log to a rotating file, and keep a pre-deploy snapshot of the <code>current<\/code> symlink target so rollback is a single <code>ln -sfn<\/code>.<\/p>\n<!-- \/wp:paragraph -->\n\n<!-- wp:paragraph -->\n<p>The total steady-state cost is about 1 GB of disk for caches and 250 MB of RAM during builds \u2014 comfortably within a small instance. If you are provisioning specifically for this pattern, the <a href=\"https:\/\/affordablevpsserver.com\/#providers\">providers listed in the comparison table<\/a> show NVMe capacity and RAM per plan, both of which matter more than CPU for cached Hugo builds.<\/p>\n<!-- \/wp:paragraph -->\n","protected":false},"excerpt":{"rendered":"<p>Hugo is fast \u2014 a 500-page site builds in under two seconds on a laptop. On a 1 vCPU \/ 1 GB VPS with no cache, the same build takes 40\u201390 seconds because it recompiles every partial, re-processes every image, and re-runs SCSS on each deploy. The build itself is rarely the whole cost; npm [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-1717","post","type-post","status-publish","format-standard","hentry","category-vps-hosting-tutorials"],"blocksy_meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM - Affordable VPS Server Blog<\/title>\n<meta name=\"description\" content=\"Hugo is fast \u2014 a 500-page site builds in under two seconds on a laptop. On a 1 vCPU \/ 1 GB VPS with no cache, the same build takes 40\u201390 seconds because\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM\" \/>\n<meta property=\"og:description\" content=\"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM\" \/>\n<meta property=\"og:url\" content=\"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/\" \/>\n<meta property=\"og:site_name\" content=\"Affordable VPS Server Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-11T12:55:21+00:00\" \/>\n<meta name=\"author\" content=\"Affordable-Vps-Server-Author\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Affordable-Vps-Server-Author\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/\",\"url\":\"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/\",\"name\":\"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM - Affordable VPS Server Blog\",\"isPartOf\":{\"@id\":\"https:\/\/affordablevpsserver.com\/blog\/#website\"},\"datePublished\":\"2026-11-11T12:55:21+00:00\",\"author\":{\"@id\":\"https:\/\/affordablevpsserver.com\/blog\/#\/schema\/person\/685a02c93a3c45030f7427ec928b0df7\"},\"description\":\"Hugo is fast \u2014 a 500-page site builds in under two seconds on a laptop. On a 1 vCPU \/ 1 GB VPS with no cache, the same build takes 40\u201390 seconds because\",\"breadcrumb\":{\"@id\":\"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/affordablevpsserver.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/affordablevpsserver.com\/blog\/#website\",\"url\":\"https:\/\/affordablevpsserver.com\/blog\/\",\"name\":\"Affordable VPS Server Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/affordablevpsserver.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/affordablevpsserver.com\/blog\/#\/schema\/person\/685a02c93a3c45030f7427ec928b0df7\",\"name\":\"Affordable-Vps-Server-Author\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/affordablevpsserver.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8fa20973a7dd04621d396c26ba26b5c5e6c19595583335121958527393f6f95e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8fa20973a7dd04621d396c26ba26b5c5e6c19595583335121958527393f6f95e?s=96&d=mm&r=g\",\"caption\":\"Affordable-Vps-Server-Author\"},\"sameAs\":[\"https:\/\/affordablevpsserver.com\/blog\"],\"url\":\"https:\/\/affordablevpsserver.com\/blog\/author\/affordablevpsserver\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM - Affordable VPS Server Blog","description":"Hugo is fast \u2014 a 500-page site builds in under two seconds on a laptop. On a 1 vCPU \/ 1 GB VPS with no cache, the same build takes 40\u201390 seconds because","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/","og_locale":"en_US","og_type":"article","og_title":"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM","og_description":"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM","og_url":"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/","og_site_name":"Affordable VPS Server Blog","article_published_time":"2026-11-11T12:55:21+00:00","author":"Affordable-Vps-Server-Author","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Affordable-Vps-Server-Author","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/","url":"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/","name":"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM - Affordable VPS Server Blog","isPartOf":{"@id":"https:\/\/affordablevpsserver.com\/blog\/#website"},"datePublished":"2026-11-11T12:55:21+00:00","author":{"@id":"https:\/\/affordablevpsserver.com\/blog\/#\/schema\/person\/685a02c93a3c45030f7427ec928b0df7"},"description":"Hugo is fast \u2014 a 500-page site builds in under two seconds on a laptop. On a 1 vCPU \/ 1 GB VPS with no cache, the same build takes 40\u201390 seconds because","breadcrumb":{"@id":"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/affordablevpsserver.com\/blog\/hugo-static-site-build-cache-on-cheap-vps\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/affordablevpsserver.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Caching Hugo Builds on a Cheap VPS: Cutting Deploy Time Without More RAM"}]},{"@type":"WebSite","@id":"https:\/\/affordablevpsserver.com\/blog\/#website","url":"https:\/\/affordablevpsserver.com\/blog\/","name":"Affordable VPS Server Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/affordablevpsserver.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/affordablevpsserver.com\/blog\/#\/schema\/person\/685a02c93a3c45030f7427ec928b0df7","name":"Affordable-Vps-Server-Author","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/affordablevpsserver.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8fa20973a7dd04621d396c26ba26b5c5e6c19595583335121958527393f6f95e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8fa20973a7dd04621d396c26ba26b5c5e6c19595583335121958527393f6f95e?s=96&d=mm&r=g","caption":"Affordable-Vps-Server-Author"},"sameAs":["https:\/\/affordablevpsserver.com\/blog"],"url":"https:\/\/affordablevpsserver.com\/blog\/author\/affordablevpsserver\/"}]}},"_links":{"self":[{"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/posts\/1717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/comments?post=1717"}],"version-history":[{"count":1,"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/posts\/1717\/revisions"}],"predecessor-version":[{"id":1733,"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/posts\/1717\/revisions\/1733"}],"wp:attachment":[{"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/media?parent=1717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/categories?post=1717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/affordablevpsserver.com\/blog\/wp-json\/wp\/v2\/tags?post=1717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}