Last active
December 22, 2015 05:59
-
-
Save robtarr/6428280 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clear_cache domain | |
domain_parts = domain.match(/(?:[^:]*:\/\/)?([^\/]+\.[^\/]+)/) | |
domain = domain_parts[1] | |
Net::HTTP.get(domain, "/") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clear_cache domain | |
raise "No domain specified." if domain.nil? | |
domain_parts = domain.match(/(?:[^:]*:\/\/)?([^\/]+\.[^\/]+)/) | |
domain = domain_parts[1] | |
Net::HTTP.get(domain, "/") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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