Agent Wranglers

Site architecture Recommended

Keep the previous build's assets

After a deploy, keep the previous build's hashed files, so pages cached before the deploy still find their scripts.

How to do it

Copy the old build's hashed asset folder into the new one without overwriting. Use cp -r --update=none on GNU systems, or cp -rn on macOS and BSD. Delete files older than a few deploys.

Example

# 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/

How to check

Load a page, deploy, then reload it from the cache. There are no 404s.

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.