From a187eeb92cee03e1259ac7de31c93460bc5450de Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 15 May 2026 13:54:27 -0700 Subject: [PATCH 1/2] Shorten TTL for the Downloader cache and clean up more often. This is part of lowering memory use. --- Modules/RSWeb/Sources/RSWeb/DownloadCache.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/RSWeb/Sources/RSWeb/DownloadCache.swift b/Modules/RSWeb/Sources/RSWeb/DownloadCache.swift index edbaaef4f..f2f503e86 100644 --- a/Modules/RSWeb/Sources/RSWeb/DownloadCache.swift +++ b/Modules/RSWeb/Sources/RSWeb/DownloadCache.swift @@ -22,7 +22,7 @@ struct DownloadCacheRecord: CacheRecord, Sendable { nonisolated final class DownloadCache: Sendable { static let shared = DownloadCache() - private let cache = Cache(timeToLive: 60 * 13, timeBetweenCleanups: 60 * 2) + private let cache = Cache(timeToLive: 60 * 3, timeBetweenCleanups: 60) init() { NotificationCenter.default.addObserver(self, selector: #selector(handleAppDidGoToBackground(_:)), name: .appDidGoToBackground, object: nil) From ff623614f30ce2cf69f0af5b929eaf8a8cbf3089 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 15 May 2026 13:55:12 -0700 Subject: [PATCH 2/2] Remove the download cache from the feed refresher. Now using other mechanisms to prevent excessive feed polling. --- .../RSWeb/Sources/RSWeb/DownloadSession.swift | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift b/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift index 8e9564561..0ab622105 100755 --- a/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift +++ b/Modules/RSWeb/Sources/RSWeb/DownloadSession.swift @@ -41,7 +41,6 @@ struct HTTP4xxResponse { private let delegate: DownloadSessionDelegate private var redirectCache = [URL: URL]() private var queue = [URL]() - private let cache = DownloadCache.shared public var progressInfo = ProgressInfo() { didSet { @@ -137,11 +136,6 @@ extension DownloadSession: @preconcurrency URLSessionTaskDelegate { return } - if let url = task.originalRequest?.url, error == nil { - Self.logger.debug("DownloadSession: Caching response for \(url)") - cache.add(url.absoluteString, data: info.data as Data, response: info.urlResponse) - } - delegate.downloadSession(self, downloadDidComplete: info.url, response: info.urlResponse, data: info.data as Data, error: error as NSError?) } } @@ -184,13 +178,6 @@ extension DownloadSession: @preconcurrency URLSessionDataDelegate { let statusCode = response.forcedStatusCode if statusCode >= 400 { - if statusCode != HTTPResponseCode.tooManyRequests { - if let urlString = response.url?.absoluteString { - Self.logger.debug("DownloadSession: Caching >= 400 response for \(urlString)") - cache.add(urlString, data: nil, response: response) - } - } - Self.logger.debug("DownloadSession: canceling task due to >= 400 response \(response)") if let url = taskInfo?.url { @@ -252,13 +239,6 @@ private extension DownloadSession { return } - // Check cache - if let cachedResponse = cache[urlToUse.absoluteString] { - Self.logger.info("DownloadSession: using cached response for \(urlToUse) - \(cachedResponse.response?.forcedStatusCode ?? -1)") - delegate.downloadSession(self, downloadDidComplete: url, response: cachedResponse.response, data: cachedResponse.data ?? Data(), error: nil) - return - } - let urlRequest: URLRequest = { var request = URLRequest(url: urlToUse) if let conditionalGetInfo = delegate.downloadSession(self, conditionalGetInfoFor: url) {