{"id":21539859,"url":"https://github.com/richardvenneman/cache_with_settings","last_synced_at":"2026-04-29T09:07:28.684Z","repository":{"id":52418162,"uuid":"185830840","full_name":"richardvenneman/cache_with_settings","owner":"richardvenneman","description":"🎎 Configurable Rails fragment caching","archived":false,"fork":false,"pushed_at":"2021-04-29T19:55:38.000Z","size":56,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-12T03:09:52.522Z","etag":null,"topics":["caching","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/richardvenneman.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-09T16:01:29.000Z","updated_at":"2023-09-12T16:37:39.000Z","dependencies_parsed_at":"2022-09-03T04:32:00.203Z","dependency_job_id":null,"html_url":"https://github.com/richardvenneman/cache_with_settings","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/richardvenneman/cache_with_settings","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardvenneman%2Fcache_with_settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardvenneman%2Fcache_with_settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardvenneman%2Fcache_with_settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardvenneman%2Fcache_with_settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/richardvenneman","download_url":"https://codeload.github.com/richardvenneman/cache_with_settings/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/richardvenneman%2Fcache_with_settings/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32418247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T06:29:02.080Z","status":"ssl_error","status_checked_at":"2026-04-29T06:29:00.631Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["caching","rails","ruby"],"created_at":"2024-11-24T04:16:34.320Z","updated_at":"2026-04-29T09:07:28.668Z","avatar_url":"https://github.com/richardvenneman.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CacheWithSettings\nCacheWithSettings allows you to add any key to partial caching cache keys. This is useful if your website is multilingual or allows the user to choose a display currency.\n\n[![Build Status](https://github.com/richardvenneman/cache_with_settings/workflows/Ruby/badge.svg)](https://github.com/richardvenneman/cache_with_settings/actions?query=workflow%3ARuby)\n[![Gem Version](https://badge.fury.io/rb/cache_with_settings.svg)](https://badge.fury.io/rb/cache_with_settings)\n\n## Problem \u0026 Solution\nIf you find yourself adding dynamic values, such as locales and currencies to your cache keys, this gem could be useful for you. Instead of:\n\n```\n  = cache [@user, I18n.locale, MoneyRails.default_currency] do\n    = render @user\n```\n\nConfigure this gem once and just write:\n\n```\n  = cache @user do\n    = render @user\n```\n\nThis gem allows you to DRY up your code and forget about including dynamic values in your cache keys.\n\n## Usage\nAfter adding the gem to your Gemfile, configure CacheWithSettings in an initializer. You can specify any dynamic cache keys, such as `I18n.locale`.\n\n```ruby\nCacheWithSettings.configure do |config|\n  # Specify a proc that returns an array of strings\n  config.cache_keys = -\u003e { [I18n.locale.to_s, MoneyRails.default_currency.to_s] }\nend\n```\n\nThat's it! Your template `cache` calls now automatically include the specified cache keys.\n\nCollection caching is also supported. If you're rendering collections with `cached: true` your specified cache keys will automatically be included:\n\n```erb\n\u003c%= render partial: \"cities/city\",\n           collection: @cities,\n           cached: true %\u003e\n```\n\n### HTTP Caching\nIf you're using a HTTP cache in production (with Rails conditional get), add the dynamic cache keys with the [`etag` directive](https://api.rubyonrails.org/classes/ActionController/ConditionalGet/ClassMethods.html#method-i-etag):\n\n```ruby\nclass ApplicationController\n  etag { CacheWithSettings.cache_keys.call.join(\"-\") }\nend\n```\n\n## Installation\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'cache_with_settings'\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\n## Credit\nThis project started as a fork of [cache_with_locale](https://github.com/igorkasyanchuk/cache_with_locale). Besides the locale I also needed the current currency as part of our cache keys, which led to the creation of this gem.\n\n## License\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardvenneman%2Fcache_with_settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frichardvenneman%2Fcache_with_settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frichardvenneman%2Fcache_with_settings/lists"}