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) 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) {