private async Task <MemoryStream> DownloadStreamAndCacheAsync(string url, string filename, string filepath, CancellationToken token, TimeSpan?duration, CacheType?cacheType)
        {
            var responseBytes = await DownloadAsync(url, filename, token).ConfigureAwait(false);

            if (responseBytes == null)
            {
                return(null);
            }

            var memoryStream = new MemoryStream(responseBytes, false);

            memoryStream.Position = 0;

            var allowDiskCaching = AllowDiskCaching(cacheType);

            if (allowDiskCaching)
            {
                await _diskCache.AddToSavingQueueIfNotExistsAsync(filename, responseBytes, duration ?? new TimeSpan(30, 0, 0, 0)); // by default we cache data 30 days)
            }

            return(memoryStream);
        }