How to access the previous deploy or published directory when building

Where or how can I access the publish directory of a previous build, my app checks if a file is present in the generated directory before building it again, for example:

  • A static website generator want’s to compile sass from the source directory
  • Before building it looks for the generated css file in the publish directory
  • If the file is present in the publish directory it checks if it’s newer than the source file
  • If the source file is newer than the published css file the static website generator compiles the sass and overwrites the previous css file
  • Else it keeps the previous file and the sass file doesn’t need to be compiled
  • Precious build minutes saved!

I could use a cache system, writing the generated css to ‘/opt/build/cache’ and compare/copy that file to the publish directory when building the site, but that seems a bit unnecessary knowing the files where already generated on a previous build…

Another solution I used in the past is writing the files back to github after build (with [skip ci] in the commit message) but that feels a little dirty…

Welcome bert-bruggerman.

It’s easy to gain access to previous builds.

In the Netlify app dashboard, select the site of interest from the list.

Click Deploys on the top menu.

This will show you the complete list of all deploys for this site. Example:

Click on the line of the deploy you want to recall. Next to the time stamp for that deploy in the page that opens, you will see a small download icon. Example:

Click it, answer the questions, and your files will soon be on their way to you.

Also this:

I would like to access the previous/current deploy in my code while building the website…
See the example in the first post…

Got it. Didn’t read far enough in your original post. Sorry.

This should be a function of your build system, which might mean this is not a question about Netlify per se. If your build system doesn’t have the smarts to figure out what needs to be built and what doesn’t, that’s not a Netlify problem, unless I’m missing something else.

A better example with a simple nodejs script (no other build system or static website generator)


  • checks if the file exists in the source dir and if it was updated since last build
  • if the source file exists and was not updated it checks if the generated file exists in the publication dir
  • if the file exists in the publication dir do nothing (the file is already present) - DONE
  • if not it generates the file to the publication dir - DONE

But where can i get the previous generated file? - the publication dir is empty when starting the next build… Where are the files of the publication dir when the build is deployed…

Hey @bert-bruggeman,
Sounds like a cool idea! Have you checked out our Build Plugins beta yet?

Netlify Build Plugins extend the functionality of the Netlify Build process. You can install plugins made by others, or write your own. You can save them locally in your repository, or share them with others via npm.

There are also quite a few cache-y plugins already developed that you could try or use to scaffold your own system:

Hi @bert-bruggeman, did you manage to solve this problem? I’m dealing with the exact same scenario.


I’d be following Greg’s or Jen’s advice:

  1. you can access your current production build via HTTP to the production URL (or the deploy specific URL if you can access it during build - note that you have full outgoing internet access during your build so you can make API calls and contact HTTP endpoints including your own currently-live site)
  2. you could use a build plugin to facilitate your workflow (this one for instance lets you cache things between builds: