mirror of
https://github.com/bitwarden/server.git
synced 2024-12-24 17:17:40 +01:00
setting for disabling icons cache
This commit is contained in:
parent
de552be25f
commit
7ee659e3b1
@ -49,7 +49,7 @@ namespace Bit.Icons.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mappedDomain = _domainMappingService.MapDomain(domain);
|
var mappedDomain = _domainMappingService.MapDomain(domain);
|
||||||
if(!_memoryCache.TryGetValue(mappedDomain, out Icon icon))
|
if(!_iconsSettings.CacheEnabled || !_memoryCache.TryGetValue(mappedDomain, out Icon icon))
|
||||||
{
|
{
|
||||||
var result = await _iconFetchingService.GetIconAsync(domain);
|
var result = await _iconFetchingService.GetIconAsync(domain);
|
||||||
if(result == null)
|
if(result == null)
|
||||||
@ -62,7 +62,7 @@ namespace Bit.Icons.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only cache not found and smaller images (<= 50kb)
|
// Only cache not found and smaller images (<= 50kb)
|
||||||
if(icon == null || icon.Image.Length <= 50012)
|
if(_iconsSettings.CacheEnabled && (icon == null || icon.Image.Length <= 50012))
|
||||||
{
|
{
|
||||||
_memoryCache.Set(mappedDomain, icon, new MemoryCacheEntryOptions
|
_memoryCache.Set(mappedDomain, icon, new MemoryCacheEntryOptions
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class IconsSettings
|
public class IconsSettings
|
||||||
{
|
{
|
||||||
|
public virtual bool CacheEnabled { get; set; }
|
||||||
public virtual int CacheHours { get; set; }
|
public virtual int CacheHours { get; set; }
|
||||||
public virtual long? CacheSizeLimit { get; set; }
|
public virtual long? CacheSizeLimit { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"iconsSettings": {
|
"iconsSettings": {
|
||||||
|
"cacheEnabled": true,
|
||||||
"cacheHours": 24,
|
"cacheHours": 24,
|
||||||
"cacheSizeLimit": null
|
"cacheSizeLimit": null
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user