RubyGems Navigation menu

mime-types 1.25

This library allows for the identification of a file's likely MIME content type. This is release 1.25, adding experimental caching and lazy loading functionality. The caching and lazy loading features were initially implemented by Greg Brockman (gdb). As these features are experimental, they are disabled by default and must be enabled through the use of environment variables. The cache is invalidated on a per-version basis; the cache for version 1.25 will not be reused for version 1.26. To use lazy loading, set the environment variable +RUBY_MIME_TYPES_LAZY_LOAD+ to any value other than 'false'. When using lazy loading, the initial startup of MIME::Types is around 12–25× faster than normal startup (on my system, normal startup is about 90 ms; lazy startup is about 4 ms). This isn't generally useful, however, as the MIME::Types database has not been loaded. Lazy startup and load is just *slightly* faster—around 1 ms. The real advantage comes from using the cache. To enable the cache, set the environment variable +RUBY_MIME_TYPES_CACHE+ to a filename where MIME::Types will have read-write access. The first time a new version of MIME::Types is run using this file, it will be created, taking a little longer than normal. Subsequent loads using the same cache file will be approximately 3½× faster (25 ms) than normal loads. This can be combined with +RUBY_MIME_TYPES_LAZY_LOAD+, but this is *not* recommended in a multithreaded or multiprocess environment where all threads or processes will be using the same cache file. As the caching interface is still experimental, the only values cached are the default MIME::Types database, not any custom MIME::Types added by users. MIME types are used in MIME-compliant communications, as in e-mail or HTTP traffic, to indicate the type of content which is transmitted. MIME::Types provides the ability for detailed information about MIME entities (provided as a set of MIME::Type objects) to be determined and used programmatically. There are many types defined by RFCs and vendors, so the list is long but not complete; don't hesitate to ask to add additional information. This library follows the IANA collection of MIME types (see below for reference). MIME::Types for Ruby was originally based on MIME::Types for Perl by Mark Overmeer, copyright 2001 - 2009. As of version 1.15, the data format for the MIME::Type list has changed and the synchronization will no longer happen. MIME::Types is built to conform to the MIME types of RFCs 2045 and 2231. It tracks the {IANA registry}[] ({ftp}[]) with some unofficial types added from the {LTSW collection}[] and added by the users of MIME::Types.


  1. 3.1 - May 22, 2016 (41.5 KB)
  2. 3.0 - November 21, 2015 (43 KB)
  3. 2.99.3 - September 11, 2016 (146 KB)
  4. 2.99.2 - May 21, 2016 (146 KB)
  5. 2.99.1 - February 22, 2016 (145 KB)
Show all versions (33 total)


  • Austin Ziegler



SHA 256 checksum:


Total downloads 119,724,260

For this version 4,180,951

= Copy to clipboard Copied!



MIT, Artistic 2.0, GPL-2

Required Ruby Version: None