Skip to content

tigris/open-uri-cached

Repository files navigation

OpenURI with caching

Carelessly make OpenURI requests without getting hate mail.

Usage

Require the library

    require 'open-uri/cached'
    open('http://www.someone-that-hates-being-scraped.com').read

Configuring

If you're not super pumped about reading files from /tmp, you can configure the cache path:

  OpenURI::Cache.cache_path = '/tmp/open-uri'

Invalidating

They say cache invalidation is hard, but not really:

  # Invalidate a single URL
  OpenURI::Cache.invalidate('https://example.com/')

  # Invalidate everything
  OpenURI::Cache.invalidate_all!

About

Disk caching for open-uri

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6