{"id":13878628,"url":"https://github.com/rack/rack-cache","last_synced_at":"2025-04-05T23:06:25.537Z","repository":{"id":37365220,"uuid":"462189648","full_name":"rack/rack-cache","owner":"rack","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-05T07:26:02.000Z","size":982,"stargazers_count":37,"open_issues_count":3,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T15:00:57.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-22T07:43:02.000Z","updated_at":"2025-03-13T20:13:11.000Z","dependencies_parsed_at":"2024-06-18T16:49:22.958Z","dependency_job_id":"e6892acc-e791-49ce-bbc5-95142adcbff5","html_url":"https://github.com/rack/rack-cache","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack%2Frack-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack%2Frack-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack%2Frack-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rack%2Frack-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rack","download_url":"https://codeload.github.com/rack/rack-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234921,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:01:55.181Z","updated_at":"2025-04-05T23:06:25.518Z","avatar_url":"https://github.com/rack.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"Rack::Cache\n===========\n\nRack::Cache is suitable as a quick drop-in component to enable HTTP caching for\nRack-based applications that produce freshness (`expires`, `cache-control`)\nand/or validation (`last-modified`, `etag`) information:\n\n  * Standards-based (RFC 2616)\n  * Freshness/expiration based caching\n  * Validation (`if-modified-since` / `if-none-match`)\n  * `vary` support\n  * `cache-control` `public`, `private`, `max-age`, `s-maxage`, `must-revalidate`,\n    and `proxy-revalidate`.\n  * Portable: 100% Ruby / works with any Rack-enabled framework\n  * Disk, memcached, and heap memory storage backends\n\nFor more information about Rack::Cache features and usage, see:\n\nhttps://rack.github.io/rack-cache/\n\nRack::Cache is not overly optimized for performance. The main goal of the\nproject is to provide a portable, easy-to-configure, and standards-based\ncaching solution for small to medium sized deployments. More sophisticated /\nhigh-performance caching systems (e.g., Varnish, Squid, httpd/mod-cache) may be\nmore appropriate for large deployments with significant throughput requirements.\n\nInstallation\n------------\n\n    gem install rack-cache\n\nBasic Usage\n-----------\n\n`Rack::Cache` is implemented as a piece of Rack middleware and can be used with\nany Rack-based application. If your application includes a rackup (`.ru`) file\nor uses Rack::Builder to construct the application pipeline, simply require\nand use as follows:\n\n```Ruby\nrequire 'rack/cache'\n\nuse Rack::Cache,\n  metastore:    'file:/var/cache/rack/meta',\n  entitystore:  'file:/var/cache/rack/body',\n  verbose:      true\n\nrun app\n```\n\nAssuming you've designed your backend application to take advantage of HTTP's\ncaching features, no further code or configuration is required for basic\ncaching.\n\nUsing with Rails\n----------------\n\n```Ruby\n# config/application.rb\nconfig.action_dispatch.rack_cache = true\n# or\nconfig.action_dispatch.rack_cache = {\n   verbose:     true,\n   metastore:   'file:/var/cache/rack/meta',\n   entitystore: 'file:/var/cache/rack/body'\n}\n```\n\nYou should now see `Rack::Cache` listed in the middleware pipeline:\n\n    rake middleware\n\n[more information](https://snippets.aktagon.com/snippets/302-how-to-setup-and-use-rack-cache-with-rails)\n\nUsing with Dalli\n----------------\n\nDalli is a high performance memcached client for Ruby.\nMore information at: https://github.com/mperham/dalli\n\n```Ruby\nrequire 'dalli'\nrequire 'rack/cache'\n\nuse Rack::Cache,\n  verbose:  true,\n  metastore:    \"memcached://localhost:11211/meta\",\n  entitystore:  \"memcached://localhost:11211/body\"\n\nrun app\n```\n\nNoop entity store\n-----------------\n\nDoes not persist response bodies (no disk/memory used).\u003cbr/\u003e\nResponses from the cache will have an empty body.\u003cbr/\u003e\nClients must ignore these empty cached response (check for `x-rack-cache` response header).\u003cbr/\u003e\nAtm cannot handle streamed responses, patch needed.\n\n```Ruby\nrequire 'rack/cache'\n\nuse Rack::Cache,\n verbose: true,\n metastore: \u003cany backend\u003e\n entitystore: \"noop:/\"\n\nrun app\n```\n\nIgnoring tracking parameters in cache keys\n-----------------\n\nIt's fairly common to include tracking parameters which don't affect the content\nof the page. Since Rack::Cache uses the full URL as part of the cache key, this\ncan cause unneeded churn in your cache. If you're using the default key class\n`Rack::Cache::Key`, you can configure a proc to ignore certain keys/values like\nso:\n\n```Ruby\nRack::Cache::Key.query_string_ignore = proc { |k, v| k =~ /^(trk|utm)_/ }\n```\n\nLicense: MIT\u003cbr/\u003e\n[![Development](https://github.com/rack/rack-cache/actions/workflows/development.yml/badge.svg)](https://github.com/rack/rack-cache/actions/workflows/development.yml)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frack%2Frack-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frack%2Frack-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frack%2Frack-cache/lists"}