diff --git a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor
index f6f65b40..335800cb 100644
--- a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor
+++ b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor
@@ -132,6 +132,12 @@
+
@@ -185,6 +191,7 @@
private string _logginglevel = string.Empty;
private string _notificationlevel = string.Empty;
private string _swagger = string.Empty;
+ private string _cachecontrol = string.Empty;
private string _packageregistryurl = string.Empty;
private string _packageregistryemail = string.Empty;
@@ -216,7 +223,8 @@
_detailederrors = systeminfo["DetailedErrors"].ToString();
_logginglevel = systeminfo["Logging:LogLevel:Default"].ToString();
_notificationlevel = systeminfo["Logging:LogLevel:Notify"].ToString();
- _swagger = systeminfo["UseSwagger"].ToString();
+ _swagger = systeminfo["UseSwagger"].ToString();
+ _cachecontrol = systeminfo["CacheControl"].ToString();
_packageregistryurl = systeminfo["PackageRegistryUrl"].ToString();
_packageregistryemail = systeminfo["PackageRegistryEmail"].ToString();
}
@@ -237,7 +245,8 @@
settings.Add("Logging:LogLevel:Default", _logginglevel);
settings.Add("Logging:LogLevel:Notify", _notificationlevel);
settings.Add("UseSwagger", _swagger);
- settings.Add("PackageRegistryUrl", _packageregistryurl);
+ settings.Add("CacheControl", _cachecontrol);
+ settings.Add("PackageRegistryUrl", _packageregistryurl);
settings.Add("PackageRegistryEmail", _packageregistryemail);
await SystemService.UpdateSystemInfoAsync(settings);
AddModuleMessage(Localizer["Success.UpdateConfig.Restart"], MessageType.Success);
diff --git a/Oqtane.Client/Resources/Modules/Admin/SystemInfo/Index.resx b/Oqtane.Client/Resources/Modules/Admin/SystemInfo/Index.resx
index f81b0663..7c4eca2e 100644
--- a/Oqtane.Client/Resources/Modules/Admin/SystemInfo/Index.resx
+++ b/Oqtane.Client/Resources/Modules/Admin/SystemInfo/Index.resx
@@ -300,4 +300,10 @@
Specify The Email Address Of The User Account Used For Interacting With The Package Manager Service. This Account Is Used For Managing Packages Across Multiple Installations.
+
+ Static Asset Caching:
+
+
+ Provide a Cache-Control directive for static assets. For example 'public, max-age=604800' indicates that static assets should be cached for 1 week. A blank value indicates no caching.
+
\ No newline at end of file
diff --git a/Oqtane.Server/Controllers/SystemController.cs b/Oqtane.Server/Controllers/SystemController.cs
index 74aa9a27..240a75eb 100644
--- a/Oqtane.Server/Controllers/SystemController.cs
+++ b/Oqtane.Server/Controllers/SystemController.cs
@@ -53,6 +53,7 @@ namespace Oqtane.Controllers
systeminfo.Add("Logging:LogLevel:Default", _configManager.GetSetting("Logging:LogLevel:Default", "Information"));
systeminfo.Add("Logging:LogLevel:Notify", _configManager.GetSetting("Logging:LogLevel:Notify", "Error"));
systeminfo.Add("UseSwagger", _configManager.GetSetting("UseSwagger", "true"));
+ systeminfo.Add("CacheControl", _configManager.GetSetting("CacheControl", "public, max-age=604800"));
systeminfo.Add("PackageRegistryUrl", _configManager.GetSetting("PackageRegistryUrl", Constants.PackageRegistryUrl));
systeminfo.Add("PackageRegistryEmail", _configManager.GetSetting("PackageRegistryEmail", ""));
break;
diff --git a/Oqtane.Server/Startup.cs b/Oqtane.Server/Startup.cs
index 7c37cc09..33e09e80 100644
--- a/Oqtane.Server/Startup.cs
+++ b/Oqtane.Server/Startup.cs
@@ -23,6 +23,7 @@ using OqtaneSSR.Extensions;
using Microsoft.AspNetCore.Components.Authorization;
using Oqtane.Providers;
using Microsoft.AspNetCore.Cors.Infrastructure;
+using Microsoft.Net.Http.Headers;
namespace Oqtane
{
@@ -98,7 +99,7 @@ namespace Oqtane
{
options.HeaderName = Constants.AntiForgeryTokenHeaderName;
options.Cookie.Name = Constants.AntiForgeryTokenCookieName;
- options.Cookie.SameSite = SameSiteMode.Strict;
+ options.Cookie.SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Strict;
options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest;
options.Cookie.HttpOnly = true;
});
@@ -171,7 +172,7 @@ namespace Oqtane
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISyncManager sync, ICorsService corsService, ICorsPolicyProvider corsPolicyProvider, ILogger logger)
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISyncManager sync, ICorsService corsService, ICorsPolicyProvider corsPolicyProvider, IConfigManager configManager, ILogger logger)
{
if (!string.IsNullOrEmpty(_configureServicesErrors))
{
@@ -205,7 +206,14 @@ namespace Oqtane
ServeUnknownFileTypes = true,
OnPrepareResponse = (ctx) =>
{
- ctx.Context.Response.Headers.Append("Cache-Control", "public, max-age=604800");
+ if (!env.IsDevelopment())
+ {
+ var cachecontrol = configManager.GetSetting("CacheControl", "public, max-age=604800");
+ if (!string.IsNullOrEmpty(cachecontrol))
+ {
+ ctx.Context.Response.Headers.Append(HeaderNames.CacheControl, cachecontrol);
+ }
+ }
var policy = corsPolicyProvider.GetPolicyAsync(ctx.Context, Constants.MauiCorsPolicy)
.ConfigureAwait(false).GetAwaiter().GetResult();
corsService.ApplyResult(corsService.EvaluatePolicy(ctx.Context, policy), ctx.Context.Response);