---
title: "Keep the previous build's assets · Agent Wranglers"
url: https://agentwranglers.se/playbook/website/site-architecture/keep-the-previous-build-s-assets
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep the previous build's assets

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Site architecture](https://agentwranglers.se/playbook/website/site-architecture)
- Rule: After a deploy, keep the hashed files of the last three deploys and of the last 7 days, whichever keeps more. Pages cached before the deploy still find their scripts.
- How: Copy the old build's hashed asset folder into the new one without overwriting. Use `cp -r --update=none` on GNU coreutils 9.3 or later, or `cp -rn` on macOS and BSD. Delete a hashed file only when no build among the last three deploys produced it and it is over 7 days old. Tabs stay open for days, and HTML may be cached for its `max-age` plus `stale-while-revalidate`. See also [recover when a new release replaces the old files](https://agentwranglers.se/playbook/app-ui/permissions-flags-and-failures/new-release-reload).
- Check: A deploy test loads a page, deploys a build with new hashes, then requests the old page's script and stylesheet addresses. Each answers 200.

Example:

```sh
# before the swap: carry old hashed files into the new build, never overwrite
cp -r --update=none /srv/site/live/assets/. /srv/site/next/assets/
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/site-architecture/keep-the-previous-build-s-assets`.

- Previous: [Give every module its own class names](https://agentwranglers.se/playbook/website/site-architecture/module-class-names)
- Next: [Audit every page in a browser before release](https://agentwranglers.se/playbook/website/site-architecture/browser-audits-before-release)
- [Site architecture](https://agentwranglers.se/playbook/website/site-architecture)
