Cached static files can outlive an application update, leaving a page paired with stale images or JavaScript. Set asp-append-version="true" on a local resource element to enable cache busting: its generated URL gains a checksum-based query string. section 26.4.1 section 26.5
Listing 26.16 Adding an image in the Views/Shared/_SimpleLayout.cshtml file
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
</head>
<body>
<div class="m-2">
<img src="/images/city.png" asp-append-version="true"
class="m-2" />
@RenderBody()
</div>
</body>
</html>
A shared Razor layout puts the attribute directly on an image: <img src="/images/city.png" asp-append-version="true" class="m-2" />. section 26.5
Check the generated image URL
Request http://localhost:5000/home/list and inspect the HTML response. The image URL appears as /images/city.png?v=KaMNDSZFAJufRcRDpKh0K_IIPNc7E. The checksum changes when the file changes, so a cache sees a new URL rather than serving its old copy. section 26.5 section 26.4.1
The same attribute works on script elements through ScriptTagHelper. It can accompany asp-src-include and asp-src-exclude; a selected local jQuery file is emitted with a ?v= checksum. File selection chooses what to load, while the versioned URL addresses stale cached content. section 26.4.1
