Skip to content

Commit 2724b88

Browse files
authored
feat(blazorui): add built-in cache busting feature to BlazorUI #11307 (#11309)
1 parent e0bf376 commit 2724b88

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

src/BlazorUI/Bit.BlazorUI/Info.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Bit.BlazorUI;
2+
3+
/// <summary>
4+
/// Provides information about the bit BlazorUI library.
5+
/// </summary>
6+
public static class Info
7+
{
8+
/// <summary>
9+
/// The current version string of bit BlazorUI.
10+
/// </summary>
11+
public static string Version { get; } = "9.11.4-pre-01";
12+
}

src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/GettingStartedPage.razor

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,17 @@
7272

7373
<section class="page-section">
7474
<BitText Typography="BitTypography.H4" Class="subtitle">2. Namespace</BitText>
75-
<div class="section-desc">Open the <BitTag Color="BitColor.TertiaryBackground">_Imports.razor</BitTag>
76-
file of your Blazor application and add this line:</div>
75+
<BitText Typography="BitTypography.Body1">
76+
Open the <BitTag Color="BitColor.TertiaryBackground">_Imports.razor</BitTag> file of your Blazor application and add this line:
77+
</BitText>
7778
<CodeBox>&#64;using Bit.BlazorUI</CodeBox>
7879
</section>
7980

8081
<section class="page-section">
8182
<BitText Typography="BitTypography.H4" Class="subtitle">3. Styles and Scripts</BitText>
8283

8384
<BitText Typography="BitTypography.Body1">
84-
Open <BitTag Color="BitColor.TertiaryBackground">App.razor</BitTag> or
85+
Open <BitTag Color="BitColor.TertiaryBackground">App.razor</BitTag> or
8586
<BitTag Color="BitColor.TertiaryBackground">index.html</BitTag> file and add the CSS file reference:
8687
</BitText>
8788
<CodeBox>&lt;link href="_content/Bit.BlazorUI/styles/bit.blazorui.css" rel="stylesheet" /></CodeBox>
@@ -117,5 +118,23 @@
117118
</BitAccordion>
118119
</section>
119120

121+
<section class="page-section">
122+
<BitText Typography="BitTypography.H4" Class="subtitle">4. Cache busting</BitText>
123+
<BitText Typography="BitTypography.Body1" Gutter>
124+
You need to make sure you've implemented a proper <b>cache busting strategy</b> for all resources mentioned above.
125+
Otherwise users will encounter issues related to cached versions of resources after you update the bit BlazorUI in your project.
126+
<br /><br />
127+
On .NET 9 or later you can simply use the new <BitTag Color="BitColor.TertiaryBackground">@@Assets[""]</BitTag> feature to
128+
fingerprint the resource files automatically.
129+
<br /><br />
130+
Also, bit BlazorUI has a built-in feature in order to resolve the cache issues easily. using this feature you can simply add
131+
a version query string to the url of the above resources like this:
132+
<CodeBox>&lt;script src="_content/Bit.BlazorUI/scripts/bit.blazorui.js?v=@@Bit.BlazorUI.Info.Version">&lt;/script></CodeBox>
133+
<b>Note</b>: You can only use this feature in the <BitTag Color="BitColor.TertiaryBackground">App.razor</BitTag> file,
134+
for other root files (like index.html in a WASM standalone project) you have to apply another solution,
135+
for example manually adding the version query string to the resrouce URLs.
136+
</BitText>
137+
</section>
138+
120139
<FeedbackSection Url="GettingStartedPage.razor" />
121140
</div>

0 commit comments

Comments
 (0)