From ac459f8e7621d2d07ea662827796b68eb6100416 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sun, 20 Dec 2020 12:35:04 -0500 Subject: [PATCH] Strategy: Temporarily remove response caching The simple approach here caches all header or body content from responses, so memory usage continually grows with each fetch. This becomes more of a notable issue with long livecheck runs (e.g., `--tap homebrew/core`). Instead, we should only cache the header/body for URLs that we know will be fetched more than once in a given run. Being able to determine which URLs will be fetched more than once requires structural changes within livecheck strategies, so this will take a bit of work to implement. I've been working on this off and on and I'll introduce a more sophisticated method of livecheck-wide caching in a later PR. In the interim time, it's best to remove this caching behavior until I've finished working on an approach that provides benefits (reducing duplicate fetches) while minimizing detriments (increased memory usage). --- Library/Homebrew/livecheck/strategy.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/livecheck/strategy.rb b/Library/Homebrew/livecheck/strategy.rb index c999fce0d3..76b4351b20 100644 --- a/Library/Homebrew/livecheck/strategy.rb +++ b/Library/Homebrew/livecheck/strategy.rb @@ -82,10 +82,6 @@ module Homebrew end def self.page_headers(url) - @headers ||= {} - - return @headers[url] if @headers.key?(url) - headers = [] [:default, :browser].each do |user_agent| @@ -113,15 +109,14 @@ module Homebrew .to_h.transform_keys(&:downcase) end - return (@headers[url] = headers) if status.success? + return headers if status.success? end headers end def self.page_content(url) - @page_content ||= {} - @page_content[url] ||= URI.parse(url).open.read + URI.parse(url).open.read end end end