Skip to content

Commit

Permalink
Add: Support instructing browsers to cache backgroundImage.
Browse files Browse the repository at this point in the history
By instructing the browser to allow caching of resources, it can significantly speed up the browser's loading of previous images (due to the use of hard disk caching).
  • Loading branch information
LamGC committed Jun 13, 2023
1 parent 6f30d4e commit 8ff70ed
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/WebSocketDataSender/WebSocketDataGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ private async Task SendCurrentBeatmapImage(IHttpContext context)
if (!File.Exists(location))
return;

bool.TryParse(context.Request.QueryString.Get("cache"), out var enableCache);
if (enableCache)
context.Response.Headers.Add("Cache-Control", "public, max-age=7200");

await using var fs = new FileStream(location, FileMode.Open, FileAccess.Read);
if (!(context.Request.QueryString.ContainsKey("width") ||
context.Request.QueryString.ContainsKey("height")))
Expand Down

0 comments on commit 8ff70ed

Please sign in to comment.