Created: 2008-03-12 13:45
Updated: 2017-07-10 09:46
License: mit


OpenURI with caching

Carelessly make OpenURI requests without getting hate mail.

Running with MemCached

Require the library

require 'openuri/memcached'

Start memcached server

ben@Spinners ~/ Ϟ memcached -d

Set your memcached host/s (defaults to = ['', '']

The default expiry is 15 minutes, this can be changed using the expiry method

# Ten long minutes
OpenURI::Cache.expiry = 600

Running using Rails cache

You can also cache your OpenURI calls using Rails cache. require the library using require openuri/rails-cache


Use exactly the same as you would OpenURI, only.. enable it.

# As slow a wet week

Quit your app (leave memcached running) and re-run the same request, It will come from cache.


  • Ruby
  • MemCached
  • memcache (gem)
    • You will need to ensure that you have corresponding version of libmemcached to the memcached gem installed for installation to go by breezy


Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more