Skip to content
Source
Sign inSign up

Update and roll back assets

Code and repositories / Assets

Update an asset and roll it back

Your docs must show the new screenshot after an update, but the launch video on a partner site must never change. Each asset has two URLs for this: one follows the current version, and one stays on a single version.

3 min read

Each upload to the same path adds a version of the asset. To replace a file or roll it back, you need write access to the repository.

1. Pick a URL

URLServesBrowsers cache it for
/@<owner>/<repo>/assets/<path>The current version1 minute
/@<owner>/<repo>/assets/<path>?v=<n>Version n only1 year
  • When your pages must show your next update, link to the URL.
  • When the file must never change, link to the pinned URL.

In the Assets tab, click the name of a file. The dialog shows both: URL with Copy URL, and Pinned URL with Copy pinned URL.

The dialog of images/hero.png, with a preview, the URL, the pinned URL with ?v=1, and versions 1 and 2 with Make current and Delete

Note

Each answer has an ETag. When the cache time ends, the browser asks again. If the file did not change, the forge answers 304 Not Modified with no body, so the short cache time costs little.

2. Replace a file

Upload a file to the same path. In the Assets tab, open its folder and drop a file with the same name. From a terminal, run src asset push dist/hero.png --to images.

The file becomes the next version (2, then 3, and so on), and it is current at once. Reload a page that uses the URL. In about 1 minute, it shows the new file.

Note

If the bytes are the same as the current version, the forge adds no version. src asset push then prints Unchanged images/hero.png.

3. Roll back

If the new file is wrong, make another version current:

  1. In the Assets tab, click the name of the file.
  2. In Versions, click Make current on the version that you want.

From a terminal, run src asset restore images/hero.png 2.

The URL serves that version again in about 1 minute. The newer versions stay. The next upload gets a new number, after the highest number so far.

Done

Your docs show the new screenshot in about a minute, and the launch video on the partner site stays the same.

Delete old versions

Old versions count toward the 10 GiB of the repository until you delete them.

Caution

You cannot undo a delete.

  • One version: in Versions, click Delete on that version. From a terminal, run src asset delete images/hero.png --version 1 --yes.
  • The asset with all its versions: click Delete asset. From a terminal, run src asset delete images/old.png --yes.

What a delete does:

  • If you delete the current version, the newest version left becomes current.
  • If you delete the only version, the asset goes too.
  • The pinned URL of a deleted version stops working. A browser that cached it keeps its copy until its cache time ends.
  • The forge never gives a version number twice, even after a delete. So a pinned URL never serves other bytes.