remove surf code, clean up purge cache and better define purge cache tests for expected behavior

This commit is contained in:
Kyle Drake 2024-02-21 13:51:41 -06:00
parent b4caf44af4
commit 29619d51ee
12 changed files with 106 additions and 395 deletions

View file

@ -11,38 +11,6 @@ class PurgeCacheWorker
end
def perform(username, path)
# Must always have a forward slash
path = '/' + path if path[0] != '/'
# Add removed html ext if present
html = path.match(/(.*)\.html?$/)
if html
PurgeCacheWorker.perform_async username, html.captures.first
end
$redis_proxy.publish 'proxy', {cmd: 'purge', path: "#{username}#{path}"}.to_msgpack
=begin
url = Addressable::URI.encode_component(
"https://#{proxy_ip}#{path}",
Addressable::URI::CharacterClasses::QUERY
)
retry_encoded = false
begin
#cmd = %{timeout 5 curl -k -I -H "Host: #{URI::encode("#{username}.neocities.org")}" -H "Cache-Purge: 1" "#{url}"}
#`#{cmd}`
ctx = OpenSSL::SSL::SSLContext.new
ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
HTTP.follow.timeout(read: 10, write: 10, connect: 5).
headers(host: URI::encode("#{username}.neocities.org"), cache_purge: '1').
head(url, ssl_context: ctx)
rescue URI::InvalidURIError
raise if retry_encoded == true
url = URI.encode url
retry_encoded = true
retry
end
=end
end
end