Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ysmoradi committed Jul 20, 2024
1 parent ad6db03 commit 66d9a2a
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 24 deletions.
14 changes: 12 additions & 2 deletions src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,26 @@

@if (HttpContext.Request.IsCrawlerClient() is false)
{
<Script src="_framework/blazor.web.js" autostart="false"></Script>
@if (AppRenderMode.PwaEnabled)
{
<Script src="_framework/blazor.web.js" autostart="false"></Script>
<Script src="_content/Bit.Bswup/bit-bswup.js"></Script>
<Script src="_content/Bit.Bswup/bit-bswup.progress.js"></Script>
<AppBswupProgressBar />
}
else
{
<Script src="_framework/blazor.web.js"></Script>
<Script>
Blazor.start({
webAssembly: {
loadBootResource: function (type, name, defaultUri, integrity) {
if (integrity != null && integrity != '')
return `${defaultUri}?v=${integrity}`;
return null; // default blazor asset loading mechanism.
}
}
});
</Script>
}
<Script src="_content/Bit.BlazorUI.Demo.Client.Core/prism-1.28.0/prism.js"></Script>
<Script src="_content/Bit.BlazorUI/scripts/bit.blazorui.js"></Script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ public static void Use(WebApplication app, IHostEnvironment env, IConfiguration

Configure_401_403_404_Pages(app);

app.UseStaticFiles(new StaticFileOptions
app.Use(async (context, next) =>
{
OnPrepareResponse = ctx =>
if (context.Request.Query.Any(q => q.Key == "v"))
{
// https://bitplatform.dev/templates/cache-mechanism
ctx.Context.Response.GetTypedHeaders().CacheControl = new()
context.Response.GetTypedHeaders().CacheControl = new()
{
MaxAge = TimeSpan.FromDays(7),
Public = true
};
}
await next.Invoke();
});
app.UseStaticFiles();

app.UseCors(options => options.WithOrigins("https://0.0.0.0" /*BlazorHybrid*/, "app://0.0.0.0" /*BlazorHybrid*/)
.AllowAnyHeader().AllowAnyMethod());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

namespace Microsoft.Extensions.Configuration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static void ConfiureMiddlewares(this WebApplication app)
// For example: Boilerplate.Shared.wasm?v=sha256-omR62jpQTLnBFNxKlIyy1c0UXx9ezLt26HgCNgXN3Gk=
context.Response.GetTypedHeaders().CacheControl = new()
{
MaxAge = TimeSpan.FromDays(365),
MaxAge = TimeSpan.FromDays(7),
Public = true
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@

@if (HttpContext.Request.IsCrawlerClient() is false)
{
<Script src="_framework/blazor.web.js"></Script>
<Script src="_framework/blazor.web.js" autostart="false"></Script>
<Script>
Blazor.start({
webAssembly: {
loadBootResource: function (type, name, defaultUri, integrity) {
if (integrity != null && integrity != '')
return `${defaultUri}?v=${integrity}`;
return null; // default blazor asset loading mechanism.
}
}
});
</Script>
<Script src="_content/Bit.BlazorUI/scripts/bit.blazorui.js"></Script>
<Script src="scripts/app.js"></Script>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ public static void Use(WebApplication app, IHostEnvironment env, IConfiguration

Configure_404_Page(app);

app.UseStaticFiles(new StaticFileOptions
app.Use(async (context, next) =>
{
OnPrepareResponse = ctx =>
if (context.Request.Query.Any(q => q.Key == "v"))
{
// https://bitplatform.dev/templates/cache-mechanism
ctx.Context.Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue()
context.Response.GetTypedHeaders().CacheControl = new()
{
MaxAge = TimeSpan.FromDays(7),
Public = true
};
}
await next.Invoke();
});
app.UseStaticFiles();

app.UseResponseCaching();
app.UseAntiforgery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@

@if (HttpContext.Request.IsCrawlerClient() is false)
{
<Script src="_framework/blazor.web.js"></Script>
<script src="_content/Bit.Butil/bit-butil.js"></script>
<Script src="_framework/blazor.web.js" autostart="false"></Script>
<Script>
Blazor.start({
webAssembly: {
loadBootResource: function (type, name, defaultUri, integrity) {
if (integrity != null && integrity != '')
return `${defaultUri}?v=${integrity}`;
return null; // default blazor asset loading mechanism.
}
}
});
</Script>
<Script src="_content/Bit.Butil/bit-butil.js"></Script>
<Script src="_content/Bit.BlazorUI/scripts/bit.blazorui.js"></Script>
<Script src="scripts/app.js"></Script>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ public static void Use(WebApplication app, IHostEnvironment env, IConfiguration

Configure_404_Page(app);

app.UseStaticFiles(new StaticFileOptions
app.Use(async (context, next) =>
{
OnPrepareResponse = ctx =>
if (context.Request.Query.Any(q => q.Key == "v"))
{
// https://bitplatform.dev/templates/cache-mechanism
ctx.Context.Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue()
// For example: Boilerplate.Shared.wasm?v=sha256-omR62jpQTLnBFNxKlIyy1c0UXx9ezLt26HgCNgXN3Gk=
context.Response.GetTypedHeaders().CacheControl = new()
{
MaxAge = TimeSpan.FromDays(7),
Public = true
};
}
await next.Invoke();
});
app.UseStaticFiles();

app.UseResponseCaching();
app.UseAntiforgery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,18 @@

@if (HttpContext.Request.IsCrawlerClient() is false)
{
<Script src="_framework/blazor.web.js"></Script>
<Script src="_framework/blazor.web.js" autostart="false"></Script>
<Script>
Blazor.start({
webAssembly: {
loadBootResource: function (type, name, defaultUri, integrity) {
if (integrity != null && integrity != '')
return `${defaultUri}?v=${integrity}`;
return null; // default blazor asset loading mechanism.
}
}
});
</Script>
<Script src="_content/Bit.BlazorUI/scripts/bit.blazorui.js"></Script>
<Script src="scripts/app.js"></Script>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ public static void Use(WebApplication app, IHostEnvironment env, IConfiguration

Configure_404_Page(app);

app.UseStaticFiles(new StaticFileOptions
app.Use(async (context, next) =>
{
OnPrepareResponse = ctx =>
if (context.Request.Query.Any(q => q.Key == "v"))
{
// https://bitplatform.dev/templates/cache-mechanism
ctx.Context.Response.GetTypedHeaders().CacheControl = new CacheControlHeaderValue()
context.Response.GetTypedHeaders().CacheControl = new()
{
MaxAge = TimeSpan.FromDays(7),
Public = true
};
}
await next.Invoke();
});
app.UseStaticFiles();

app.UseResponseCaching();
app.UseAntiforgery();
Expand Down

0 comments on commit 66d9a2a

Please sign in to comment.