Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
beyaz committed Nov 15, 2024
1 parent f1355e1 commit 7de5eba
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ReactWithDotNet/UIDesigner/ReactWithDotNetJavaScriptFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ public ReactWithDotNetJavaScriptFiles(RequestDelegate next)
_next = next;
}

/// <summary>
/// Default value is 5 minute.
/// </summary>
public static TimeSpan Timeout { get; set; } = TimeSpan.FromMinutes(5);

public async Task InvokeAsync(HttpContext context)
{
var content = TryGetContentOfJsFile(context);
if (content != null)
{
context.Response.ContentType = content.Type;

context.Response.Headers.Append("Cache-Control", $"public, max-age={Timeout.TotalSeconds}");

await context.Response.Body.WriteAsync(content.Data);

return;
Expand All @@ -35,7 +42,7 @@ public async Task InvokeAsync(HttpContext context)
ContentInfo TryGetContentOfJsFile(HttpContext context)
{
const string ContentTypeApplication_Javascript = "application/javascript";

const string ContentTypeText_Css = "text/css";

var httpRequest = context.Request;
Expand Down Expand Up @@ -72,7 +79,7 @@ ContentInfo TryGetContentOfJsFile(HttpContext context)

resourceName = requestPath;
}

if (requestPath == "/clr.js" || requestPath == "/long.js")
{
if (Environment.UserName == "beyaz")
Expand Down

0 comments on commit 7de5eba

Please sign in to comment.