Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Docfx.App/RunServe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ public static IApplicationBuilder UseServe(this WebApplication app, string folde

// Fix the issue that .JSON file is 404 when running docfx serve
fileServerOptions.StaticFileOptions.ServeUnknownFileTypes = true;

// Set `Cache-Control` response header. (To avoid browser's default heuristic cache)
fileServerOptions.StaticFileOptions.OnPrepareResponse = ctx =>
{
var headers = ctx.Context.Response.GetTypedHeaders();
headers.CacheControl = new Microsoft.Net.Http.Headers.CacheControlHeaderValue
{
MaxAge = TimeSpan.FromSeconds(60),
};
};

return app.UseFileServer(fileServerOptions);
}

Expand Down