Skip to content

How to cache static files in blazor .net 8 #53338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MahdiElahi opened this issue Jan 12, 2024 · 4 comments
Closed

How to cache static files in blazor .net 8 #53338

MahdiElahi opened this issue Jan 12, 2024 · 4 comments
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue question Status: Resolved

Comments

@MahdiElahi
Copy link

Hi,
How to cache static files in blazor .net 8 ?
we used asp-append-version="true" in last , but how cache these static files ?

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Jan 12, 2024
@javiercn
Copy link
Member

Dupe of #31922

@javiercn javiercn added question ✔️ Resolution: Duplicate Resolved as a duplicate of another issue labels Jan 15, 2024
@ghost ghost added the Status: Resolved label Jan 15, 2024
@MahdiElahi
Copy link
Author

Thanks @javiercn
but can't find any thing to solve this problem
in the #31922 say use asp-append-version
but asp-append-version it's not exsist and worked in blazor wep app .net 8 .

how to cache static files in .net 8 Blazor

please show a simple example

@ghost
Copy link

ghost commented Jan 16, 2024

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Jan 16, 2024
@softlion
Copy link

softlion commented Jan 20, 2024

I used asp-append-version="true" too in net7's App.razor file, but tag helpers are no more available in net8 components.
Some guy posted this workaround:

@using Microsoft.AspNetCore.Mvc.ViewFeatures
@inject IFileVersionProvider FileVersionProvider

<link rel="stylesheet" href="@AppendVersion("css/site.css")" />

@code{
    private string AppendVersion(string path) => FileVersionProvider.AddFileVersionToPath("/",path);
}

Note that you will need to add builder.Services.AddMvc() to register the IFileVersionProvider.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue question Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants