U6: IndexHtmlInjector (markers OFFERINGS-JSON-LD / OFFERINGS-HTML), 60s cache, invalidatie bij wijziging, ETag

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 23:48:48 +01:00
co-authored by Claude Sonnet 5.5
parent a7460a0f9b
commit 284ff1f91a
9 changed files with 430 additions and 2 deletions
@@ -148,6 +148,32 @@ public static class StaticContentExtensions
}
context.Response.ContentType = "text/html; charset=utf-8";
// Modules fill marker comments in index.html (e.g. the current offerings); cached, with an ETag.
var injector = context.RequestServices.GetService<IndexHtmlInjector>();
var page = injector is null
? null
: await injector.GetAsync(websiteIndex, context.Request, context.RequestAborted);
if (page is not null)
{
context.Response.Headers["Cache-Control"] = "no-cache";
context.Response.Headers["ETag"] = page.ETag;
if (context.Response.StatusCode == StatusCodes.Status200OK
&& context.Request.Headers.IfNoneMatch.Contains(page.ETag))
{
context.Response.StatusCode = StatusCodes.Status304NotModified;
return;
}
context.Response.ContentLength = page.Body.Length;
if (!HttpMethods.IsHead(context.Request.Method))
{
await context.Response.Body.WriteAsync(page.Body, context.RequestAborted);
}
return;
}
await context.Response.SendFileAsync(websiteIndex);
return;
}