A cache subtracts elapsed seconds from the answer TTL.

highlighted = computed this step

Elapsed time is subtracted

The cache starts at TTL 300 and subtracts elapsed seconds.

start TTL=300\text{start TTL}=300
Subtract elapsed secondsRemaining TTL is recomputed from elapsed seconds.DNS TTL countdown - www.example.com A 93.184.216.34, TTL 300 secondselapsedremainingvalidstate0300yesvalid120180yesvalid3000noexpired

After elapsed time

After 120 seconds, remaining TTL is 180.

300120=180300 - 120=180
Subtract elapsed secondsRemaining TTL is recomputed from elapsed seconds.DNS TTL countdown - www.example.com A 93.184.216.34, TTL 300 secondselapsedremainingvalidstate0300yesvalid120180yesvalid3000noexpired

A positive remainder is valid

Because the remaining TTL is still above zero, the toy cache can still use the answer.

remaining=180\text{remaining}=180
Subtract elapsed secondsRemaining TTL is recomputed from elapsed seconds.DNS TTL countdown - www.example.com A 93.184.216.34, TTL 300 secondselapsedremainingvalidstate0300yesvalid120180yesvalid3000noexpired

Summary

Remaining TTL is starting TTL minus elapsed seconds, clamped at zero.

remaining=180\text{remaining}=180
Subtract elapsed secondsRemaining TTL is recomputed from elapsed seconds.DNS TTL countdown - www.example.com A 93.184.216.34, TTL 300 secondselapsedremainingvalidstate0300yesvalid120180yesvalid3000noexpired