diff --git a/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor b/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor index e0fac6aeca..b7c237cbc2 100644 --- a/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor +++ b/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Components/App.razor @@ -62,16 +62,26 @@ @if (HttpContext.Request.IsCrawlerClient() is false) { + @if (AppRenderMode.PwaEnabled) { - } else { - + } diff --git a/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs b/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs index 2055602f16..85cf263229 100644 --- a/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs +++ b/src/BlazorUI/Demo/Bit.BlazorUI.Demo.Server/Startup/Middlewares.cs @@ -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()); diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Extensions/IConfigurationBuilderExtensions.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Extensions/IConfigurationBuilderExtensions.cs index d7c0581c03..945873d39d 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Extensions/IConfigurationBuilderExtensions.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Extensions/IConfigurationBuilderExtensions.cs @@ -1,5 +1,4 @@ using System.Reflection; -using Microsoft.AspNetCore.Components.WebAssembly.Hosting; namespace Microsoft.Extensions.Configuration; diff --git a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs index 708737c23f..9549231da2 100644 --- a/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs +++ b/src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Web/Program.Middlewares.cs @@ -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 }; } diff --git a/src/Websites/Careers/src/Bit.Websites.Careers.Server/Components/App.razor b/src/Websites/Careers/src/Bit.Websites.Careers.Server/Components/App.razor index 9de383460a..3ec293773a 100644 --- a/src/Websites/Careers/src/Bit.Websites.Careers.Server/Components/App.razor +++ b/src/Websites/Careers/src/Bit.Websites.Careers.Server/Components/App.razor @@ -23,7 +23,18 @@ @if (HttpContext.Request.IsCrawlerClient() is false) { - + + } diff --git a/src/Websites/Careers/src/Bit.Websites.Careers.Server/Startup/Middlewares.cs b/src/Websites/Careers/src/Bit.Websites.Careers.Server/Startup/Middlewares.cs index f4798d6dc9..c45a817509 100644 --- a/src/Websites/Careers/src/Bit.Websites.Careers.Server/Startup/Middlewares.cs +++ b/src/Websites/Careers/src/Bit.Websites.Careers.Server/Startup/Middlewares.cs @@ -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(); diff --git a/src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor b/src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor index e83c836248..4d46ac2ddf 100644 --- a/src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor +++ b/src/Websites/Platform/src/Bit.Websites.Platform.Server/Components/App.razor @@ -44,8 +44,19 @@ @if (HttpContext.Request.IsCrawlerClient() is false) { - - + + + } diff --git a/src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Middlewares.cs b/src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Middlewares.cs index 002a4771ca..e6eae8a2b3 100644 --- a/src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Middlewares.cs +++ b/src/Websites/Platform/src/Bit.Websites.Platform.Server/Startup/Middlewares.cs @@ -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(); diff --git a/src/Websites/Sales/src/Bit.Websites.Sales.Server/Components/App.razor b/src/Websites/Sales/src/Bit.Websites.Sales.Server/Components/App.razor index 4b4bb75f29..a8d075c6b6 100644 --- a/src/Websites/Sales/src/Bit.Websites.Sales.Server/Components/App.razor +++ b/src/Websites/Sales/src/Bit.Websites.Sales.Server/Components/App.razor @@ -44,7 +44,18 @@ @if (HttpContext.Request.IsCrawlerClient() is false) { - + + } diff --git a/src/Websites/Sales/src/Bit.Websites.Sales.Server/Startup/Middlewares.cs b/src/Websites/Sales/src/Bit.Websites.Sales.Server/Startup/Middlewares.cs index de85e37f8b..e6e47a36e2 100644 --- a/src/Websites/Sales/src/Bit.Websites.Sales.Server/Startup/Middlewares.cs +++ b/src/Websites/Sales/src/Bit.Websites.Sales.Server/Startup/Middlewares.cs @@ -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();