Advanced

Assets with a version in the name

An asset is a file that a page points at. The name of the asset is the address, and the address is why an old page can still be read.

What you will see

2. Two names kept is what a cached page still reads.

About 1 min of reading

Try It

Name an asset with a version

1

Write the versioned name

printf 'site.a1b2c3.css\n' > /tmp/a.txt; cat /tmp/a.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One name with a version in it. The name cannot change.
2

Answer a request

printf 'site.css\n' | awk '{print $1 " a1b2c3"}'

Before you run it, say out loud what it will print. Then open the answer.

What it prints
The pair. A request and an answer is what is compared.
3

Keep an old name

printf 'site.a1b2c3.css\nsite.d4e5f6.css\n' > /tmp/k.txt; wc -l < /tmp/k.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
2. Two names kept is what a cached page still reads.

Data Flow

A request to a versioned name
1 The assets are walked and named with a version
↓
2 The page asks for a name
↓
3 The build answers with the versioned name
↓
4 The pair is compared and printed
Why this works
Why the name is the version

A name that changes is a name a reader cannot trust. A version in the name is a name that cannot change.

The failure at this step

A page that points at a name that was not built. The pair is the answer, and the answer names both.

Examples

The version is in the name

The name carries the version. A name that carries a version is a name that never changes.

The resolve is done before the compare

The page asks for a name and the build answers with a name. The answer is the pair, and the pair is what is compared.

An old name is kept

Kept, not replaced. Kept is what makes a page that was cached still render.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← The build answers with a report
Previous Lesson
The build answers with a report
Next Lesson
Caching by content, not by time
Caching by content, not by time →