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!

Developer technologies .NET Blazor
Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.