Setting Cache-Control Header on Static Files in a Maui Blazor App

Kevin Greer 21 Reputation points
2022-08-24T00:37:51.93+00:00

Hello,

Is there anyway to set the Cache-Control header on static files in a Maui Blazor App? It is currently set to the following values for all static files:

Cache-Control: no-cache, max-age=0, must-revalidate, no-store

In other Web Apps I have set it using app.UseStaticFiles in the Startup.cs file. Is there anything similar for a Maui Blazor App? Or is it possible to use custom middleware?

Thank you in advance!

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,403 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,922 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 56,931 Reputation points
    2022-08-25T02:22:44.133+00:00

    As a Maui blazor app hosting the webview reads directly from the file system, there is no code to implement caching headers, nor do the static files get proceed by blazor.

    TheMaui app could implement a caching strategy for the hosted webview, but it would vary by o/s

    If the files are public urls, rather than wwwroot, the host controls caching tags.

    0 comments No comments

0 additional answers

Sort by: Most helpful