Skip to content

Instantly share code, notes, and snippets.

@robtarr
Last active December 22, 2015 05:59
Show Gist options
  • Save robtarr/6428280 to your computer and use it in GitHub Desktop.
Save robtarr/6428280 to your computer and use it in GitHub Desktop.
def clear_cache domain
domain_parts = domain.match(/(?:[^:]*:\/\/)?([^\/]+\.[^\/]+)/)
domain = domain_parts[1]
Net::HTTP.get(domain, "/")
end
def clear_cache domain
raise "No domain specified." if domain.nil?
domain_parts = domain.match(/(?:[^:]*:\/\/)?([^\/]+\.[^\/]+)/)
domain = domain_parts[1]
Net::HTTP.get(domain, "/")
end
require 'logger'
require 'net/http'
@log = Logger.new(STDOUT)
@log.level = Logger::WARN
def clear_cache domain
if domain.nil?
@log.warn "No domain specified."
else
begin
uri = URI(domain)
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
request = Net::HTTP::Get.new uri
end
rescue
@log.warn "Error reaching #{domain}."
end
end
end
clear_cache "robtarr.net"
puts "This code should still execute without any issues."
def clear_cache domain
domain.gsub!(/http\:\/\//,"")
Net::HTTP.get(domain, "/")
end
clear_cache "http://example.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment