Skip to content

StaticWebAssetContentTypeMapping cache not being used #49366

Open
@wozzo

Description

@wozzo

Describe the bug

The Cache-Control header for different file types added as static assets using MapStaticAssets has been overrideable using a StaticWebAssetContentTypeMapping property in the csproj file on SDK versions between 9.0.101 and 9.0.205.

Updating to 9.0.300+ causes these to be ignored

To Reproduce

  <PropertyGroup>
    <StaticWebAssetImmutableCacheControlHeader>public, max-age=31536000, immutable</StaticWebAssetImmutableCacheControlHeader>
    <StaticWebAssetNeverCacheControlHeader>no-store, must-revalidate, no-cache</StaticWebAssetNeverCacheControlHeader>
  </PropertyGroup>

  <ItemGroup>
    <StaticWebAssetContentTypeMapping Cache="$(StaticWebAssetNeverCacheControlHeader)" Include="text/html" Pattern="*.html" Priority="2" />
    <StaticWebAssetContentTypeMapping Cache="$(StaticWebAssetNeverCacheControlHeader)" Include="text/html" Pattern="*.html.gz" Priority="2" />
    <StaticWebAssetContentTypeMapping Cache="$(StaticWebAssetImmutableCacheControlHeader)" Include="text/javascript" Pattern="*.js" Priority="2" />
    <StaticWebAssetContentTypeMapping Cache="$(StaticWebAssetImmutableCacheControlHeader)" Include="text/javascript" Pattern="*.js.gz" Priority="2" />

and call MapStaticAssets

Requesting a html file should return a Cache-Control header with the value public, max-age=31536000, immutable
If the SDK version is changed to 9.0.300 or above then this custom value is ignored and the default is used.

Exceptions (if any)

No exceptions

Further technical details

PS C:\Projects\MCO> dotnet --info
.NET SDK:
 Version:           9.0.203
 Commit:            dc7acfa194
 Workload version:  9.0.200-manifests.07067f5b
 MSBuild version:   17.13.20+a4ef1e90f

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26100
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.203\

.NET workloads installed:
 [aspire]
   Installation Source: VS 17.14.36203.30
   Manifest Version:    8.2.2/8.0.100
   Manifest Path:       C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
   Install Type:              Msi

Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.6
  Architecture: x64
  Commit:       3875b54e7b

.NET SDKs installed:
  9.0.203 [C:\Program Files\dotnet\sdk]
  9.0.301 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 8.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  Not set

global.json file:
  C:\Projects\MCO\global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-AspNetCoreRazorSDK, BlazorWebAssemblySDK, dotnet-watchuntriagedRequest triage from a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions