dotnet / dotnet/aspnetcore

MapStaticAssets doesn't add correct Cache-Control headers

Open
#65,463 5 comments 0 reactions 0 assignees View on GitHub
area-ui-rendering Author: Migration Bot :robot: Needs: Attention :wave:
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/MapStaticAssets-doesnt-add-correct-Cach/11020939)._

---
Hi,

The documentation says this about MapStaticAssets, “Fingerprinted assets are cached using the immutable directive, which results in the browser never requesting the asset again until it changes. For browsers that don’t support the immutable directive, a max-age directive is added”
[https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-10.0](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-10.0)

But the published app doesn’t add these headers, so the browser validates with the server on every new request—effectively treating it as no-cache—instead of loading it from disk or memory. The results from latest Asp.Net MVC template. Am I missing something here ?

![resim.png](https://aka.ms/dc/image?name=Bf49f1ee7ac2340d0a65a38f43b2bbcc2639020866916096159_20251223-143810-resim.png&tid=f49f1ee7ac2340d0a65a38f43b2bbcc2639020866916096159)

Initial response:

```

HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 231
Content-Type: text/css
Content-Encoding: br
Last-Modified: Tue, 23 Dec 2025 10:57:40 GMT
Accept-Ranges: bytes
ETag: "FVzJe6Q2UlG8wiE0wKPzsNcJ5m9zWTbKIN9rO8SkzT8="
Vary: Accept-Encoding
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Tue, 23 Dec 2025 11:31:13 GMT

```

Subsquent response:

```
HTTP/1.1 304 Not Modified
Cache-Control: no-cache
Content-Type: text/css
Content-Encoding: br
Last-Modified: Tue, 23 Dec 2025 10:57:40 GMT
Accept-Ranges: bytes
ETag: "FVzJe6Q2UlG8wiE0wKPzsNcJ5m9zWTbKIN9rO8SkzT8="
Vary: Accept-Encoding
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Tue, 23 Dec 2025 11:34:36 GMT

```

---
### Original Comments

#### Feedback Bot on 12/25/2025, 10:05 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the documentation for MapStaticAssets with the response headers from the latest ASP.NET MVC template and the published app. Trace the MapStaticAssets behavior responsible for static asset caching, then verify that fingerprinted assets receive the documented Cache-Control directives rather than no-cache. A complete fix should also demonstrate the corrected headers in a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.