How to delete old deploys

Hello,

How can I delete old deploys. I have bunch of them. I want to get rid of them. I am manually deploying. So there are only dates of deploys not any message. Old deploys basically means nothing to me. I have git in my system tracking the builds…

I have seen an old post that there were no capability to delete…(I am suprized to read that)

I wonder if there are any change in this capability.

Beni.

HI, @benibilme, and welcome to the Netlify community site. :slight_smile:

Part of the design of Netlify involves the concept of atomic deploys. Each deploy contains all the information required for the deploy. You can publish previous deploys to roll back to that exact version of the site. Click a button in the UI and the previous version is live.

However, we also don’t automatically invalidate assets when new deploys occur. (We do automatically invalidate any cached content that does change - more about that here.)

If the asset at a specific URL doesn’t change between deploys and a site visitor that already has that asset in the browser cache, they will get a 304 for that asset which is much faster than resending the unchanged file with a 200.

So deploys are atomic but new deploys also don’t automatically invalidate the browser cache unless the assets themselves actually changed between deploys.

I mention this because it is part of the reason that previous deploys cannot be deleted and one reason that this is unlikely to change.

There is a workaround but it can be labor intensive. You can create a new site and the new site will have no deploy history. Again though, this will most often involve a manual process of moving any site settings (custom domains, webhooks, environment variables, etc) from the original site to the new site which is the downside of this workaround. You can even rename the original site (the sitename.netlify.com subdomain) to a different name (example: sitename-temp.netlify.com) and then reclaim that original subdomain on the new site.

If there are other questions about this, we are happy to answer.

I was going to ask the same question… but, I’ll ask a follow-up question:

Couldn’t you set it so the owner of the Netlify account/site can click a simple checkbox in the settings, to “purge deploys older than X months/years old”? And retain the last 5 most recent deployment artifacts no matter how old they are.

I understand the atomic explanation, just seems like a waste of space retaining artifacts older than 1 year even.

2 Likes

Hi, @zim. Again, that would require a design of deploys. Newer deploys don’t include files which are already uploaded in a previous deploy.

When I said “Each deploy contains all the information required for the deploy” that doesn’t mean we make two copies of a single file. Keeping two identical copies of the same file would be wasteful and we don’t do that.

If the file changes, then a new copy is stored. However, if a file is unchanged between deploys (or if it exists in any previous deploy for the same site - say you rolled back to a version from ten deploys ago), we will just reference the existing copy of the file. Even the API only requires the checksums before upload. The API then prompts only for the files which have changed to be uploaded.

This also means that newer deploys depend on the files uploaded by previous deploys for the same site. You cannot delete the previous deploys because the files required for a newer deploy will then be deleted as well.

If you really want to delete previous deploys for a site it is all or nothing. You can completely delete the site and start over. This will delete all the deploys at once. There is no picking and choosing which deploys to delete precisely because newer deploys can depend on previous deploys.

There is a feature request to be able to delete deploys. However, there is no guarantee of when or even if this will ever be possible. If it does change, though, we will post an update here to let you know. If there are other questions please reply anytime.

1 Like

Understood. Thank you

Hi Luke, long-time reader, first-time poster. Thanks for everything you do, Netlify is a great service.

I’m trying to establish the behaviour on Netlify when deleting files (in Hugo).

I just deployed my site without its index.xml sitemap (it previously had one) and the sitemap is still live, many minutes after the deploy. This makes sense given the quote above.

However, I also previously deleted an image (specifically, I deleted example.png and replaced it with example.jpg) and the original image is 404.

So I’m wondering: is there different behaviour for XML and image (e.g. PNG) files? And if so, could we please get a list of which filetypes are deleted and which are not?

Happy to provide specifics and commit IDs if you like.

Thanks in advance!
Ron

Hi, @moonbooth. The index.xml file should disappear and also return a 404 if it was removed.

If you are still seeing an index.xml, there is either a bug or you didn’t actually remove the file. Would you send us the deploy id for the affected deploy (or a link to the site)?

Thanks Luke. The deploy ID is 5fd7dab4da80d9000714c3ed

Before posting my earlier comment, I confirmed that Hugo would indeed remove the index.xml file by generating the public folder locally on my machine. Again, this index.xml file was published in previous deploys, which lead to my question.

Thanks heaps, I appreciate it!
Cheers,
Ron

Hi, @moonbooth. Did you download the deploy? It definitely does contain the index.xml file.

The next step with be to troubleshoot to find out why the build at Netlify doesn’t match your local build. I see the Netlify build is using Hugo 0.76.5 and the build command is hugo --gc --minify --buildFuture. Does this match your local configuration?

Also, have you testing making a fresh clone of your repo to a new directory to make sure you don’t have something in the local working directory which isn’t in the repo itself?

If there are other questions, please let us know.

Hey again Luke. Thanks for this. Didn’t know you could download a deploy; good to know!

And thanks for the troubleshooting suggestions. I have resolved the issue, and after a new deploy, the file is gone, which is/was the desired behaviour.

Turns out I had removed Hugo’s sitemap.xml file but not its RSS index.xml file. The latter is named generically (personally I think it should have been called rss.xml to avoid confusion) and I think I was thinking of one when I meant to deal with the other.

For future reference, if anyone wants to remove both the XML sitemap and the RSS feed from their Hugo site, here’s the line you need in your config.toml file:

disableKinds = ["sitemap", "RSS"]

Thanks again for your help Luke!

Hi, @moonbooth. Thank you for following up to share the solution here. Our support team appreciates the extra effort to close the loop and, almost certainly, other people searching for answers in the future will thank you as well.

No one likes a DENVERCODER9 scenario:

You have made sure that doesn’t happen here and thanks again for taking the time to share the knowledge. :+1: