mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-28 23:52:36 +01:00
Merge pull request #1197 from tgstation/CacheHarder
Infinitely cache .js files served from /app
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using System;
|
||||
using System.Net.Mime;
|
||||
using Tgstation.Server.Host.Core;
|
||||
@@ -42,6 +44,10 @@ namespace Tgstation.Server.Host.Controllers
|
||||
var contentTypeProvider = new FileExtensionContentTypeProvider();
|
||||
if (!contentTypeProvider.TryGetContentType(fileInfo.Name, out var contentType))
|
||||
contentType = MediaTypeNames.Application.Octet;
|
||||
else if (contentType == MediaTypeNames.Application.Json)
|
||||
Response.Headers.Add(
|
||||
HeaderNames.CacheControl,
|
||||
new StringValues(new[] { "public", "max-age=31536000", "immutable" }));
|
||||
|
||||
return File(appRoute, contentType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user