diff --git a/src/Icons/Controllers/IconsController.cs b/src/Icons/Controllers/IconsController.cs index ac9e60d669..b15e947de3 100644 --- a/src/Icons/Controllers/IconsController.cs +++ b/src/Icons/Controllers/IconsController.cs @@ -49,7 +49,7 @@ namespace Bit.Icons.Controllers } 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); if(result == null) @@ -62,7 +62,7 @@ namespace Bit.Icons.Controllers } // 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 { diff --git a/src/Icons/IconsSettings.cs b/src/Icons/IconsSettings.cs index 809df7d09f..e6de866291 100644 --- a/src/Icons/IconsSettings.cs +++ b/src/Icons/IconsSettings.cs @@ -2,6 +2,7 @@ { public class IconsSettings { + public virtual bool CacheEnabled { get; set; } public virtual int CacheHours { get; set; } public virtual long? CacheSizeLimit { get; set; } } diff --git a/src/Icons/appsettings.json b/src/Icons/appsettings.json index 63e7df9f9f..cf5e1e7493 100644 --- a/src/Icons/appsettings.json +++ b/src/Icons/appsettings.json @@ -13,6 +13,7 @@ } }, "iconsSettings": { + "cacheEnabled": true, "cacheHours": 24, "cacheSizeLimit": null }