image caching fix
This commit is contained in:
parent
cdd6107319
commit
b7992bc919
@ -339,6 +339,7 @@ namespace RMuseum.Controllers
|
||||
}
|
||||
|
||||
Response.GetTypedHeaders().LastModified = lastModified;
|
||||
Response.Headers.CacheControl = nocache ? "no-cache" : "public,max-age=86400";
|
||||
|
||||
var requestHeaders = Request.GetTypedHeaders();
|
||||
if (requestHeaders.IfModifiedSince.HasValue &&
|
||||
@ -386,11 +387,16 @@ namespace RMuseum.Controllers
|
||||
|
||||
if (res.Result)
|
||||
{
|
||||
var cacheKey = $"poet/image/{poet.Result.Cat.UrlSlug}.png";
|
||||
var cacheKey = $"poet/image/{poet.Result.Cat.UrlSlug}.gif";
|
||||
var cacheKeyForLastModified = $"{cacheKey}/lastModified";
|
||||
if (_memoryCache.TryGetValue(cacheKey, out string imagePath))
|
||||
{
|
||||
_memoryCache.Remove(cacheKey);
|
||||
}
|
||||
if (_memoryCache.TryGetValue(cacheKeyForLastModified, out DateTime cachedLastModified))
|
||||
{
|
||||
_memoryCache.Remove(cacheKeyForLastModified);
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(res.Result);
|
||||
|
||||
@ -52,6 +52,7 @@ namespace RMuseum.Controllers
|
||||
|
||||
|
||||
Response.GetTypedHeaders().LastModified = img.Result.LastModified;
|
||||
Response.Headers.CacheControl = "public,max-age=86400";
|
||||
|
||||
var requestHeaders = Request.GetTypedHeaders();
|
||||
if (requestHeaders.IfModifiedSince.HasValue &&
|
||||
|
||||
Loading…
Reference in New Issue
Block a user