{"id":13805742,"url":"https://github.com/bazaarvoice/dropwizard-caching-bundle","last_synced_at":"2026-01-10T09:06:53.336Z","repository":{"id":18652677,"uuid":"21859706","full_name":"bazaarvoice/dropwizard-caching-bundle","owner":"bazaarvoice","description":"Response caching bundle for Dropwizard resources","archived":true,"fork":false,"pushed_at":"2022-08-27T06:20:19.000Z","size":170,"stargazers_count":8,"open_issues_count":10,"forks_count":6,"subscribers_count":27,"default_branch":"master","last_synced_at":"2024-08-04T01:05:22.652Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bazaarvoice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-15T13:02:01.000Z","updated_at":"2023-05-13T17:57:32.000Z","dependencies_parsed_at":"2022-08-05T00:16:14.546Z","dependency_job_id":null,"html_url":"https://github.com/bazaarvoice/dropwizard-caching-bundle","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazaarvoice%2Fdropwizard-caching-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazaarvoice%2Fdropwizard-caching-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazaarvoice%2Fdropwizard-caching-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazaarvoice%2Fdropwizard-caching-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bazaarvoice","download_url":"https://codeload.github.com/bazaarvoice/dropwizard-caching-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254030967,"owners_count":22002681,"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-04T01:01:04.407Z","updated_at":"2026-01-10T09:06:52.979Z","avatar_url":"https://github.com/bazaarvoice.png","language":"Java","funding_links":[],"categories":["Open Source"],"sub_categories":["Eclipse"],"readme":"Response caching bundle for Dropwizard resources.\n\nThere are two functions supported by the bundle: generate cache-control options for resources and caching responses.\nThe cache-control generation can be used without the response caching. For example, if there is already an upstream\nHTTP caching proxy.\n\nThe cache support handles the various HTTP request and response cache-control options to ensure that\nthe resource method is only invoked if the response can not be served from the cache.\n\n* For Dropwizard 0.6: use caching bundle 1.X\n* For Dropwizard 0.7: use caching bundle 2.X\n\n# Cache Keys\n\nThe cache key generated by the bundle includes:\n\n* Request method\n* Request path\n* Request query parameters\n* A hash of\n    * Request body if @IncludeBodyInCacheKey annotation is enabled\n    * Headers from the @Vary annotation\n\n# Initialize\n\n1. Add the maven dependency:\n\n    ```xml\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.bazaarvoice.dropwizard\u003c/groupId\u003e\n        \u003cartifactId\u003edropwizard-caching-bundle\u003c/artifactId\u003e\n        \u003cversion\u003e${dropwizard-caching-bundle.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n    ```\n2. Modify your application configuration class to implement `com.bazaarvoice.dropwizard.caching.CachingBundleConfiguration`\n3. Load the bundle when during application bootstrap:\n\n    ```java\n    public void initialize(Bootstrap\u003cExampleConfiguration\u003e bootstrap) {\n        bootstrap.addBundle(new CachingBundle());\n    }\n    ```\n    \nAt this point, the caching bundle has been loaded into the application. However, the caching bundle has no effect until\nconfigured.\n\n# Configuration\n\n## Cache Control\n\nThe first step in configuring caching is to specify the caching options for different resource methods.\nUse the `com.bazaarvoice.dropwizard.caching.CacheGroup` annotation on resource methods to set the\ngroup name.\n \n```yaml\n# A list of caching configuration options. The first set of options that match a resource will be\n# used.\ncacheControl:\n      # Only one of group or groupRegex can be specified. If neither is specified, the settings\n      # will be used for all resources that were not matched by previous settings and all GET\n      # methods without an explicit group name.\n    - group: pattern    # Optional. Simple pattern that matches cache group name. * can be used\n                        # to match 0 or more characters.\n      groupRegex: regex # Optional. Regular expression that matches cache group name.\n      \n      # For more detailed info on the following cache-control options,\n      # see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9\n      \n      maxAge: duration          # Optional. Max time that the response can be cached.\n                                # Example: 5m (5 minutes), 30s (30 seconds)\n                                # Resolution is seconds. Partial seconds are rounded down.\n                                # Supported suffixes: s (seconds), m (minutes), h (hours), d (days)\n                                # Although you can set this value higher, the max recommended\n                                # value by the HTTP standard is 1 year (365d).\n      sharedMaxAge: duration    # Optional. Max time that the response can be cached in a\n                                # shared cache. If specified, this value is used by the caching\n                                # layer. Otherwise, maxAge is used. A shared cache is one where a\n                                # cached response can be returned to multiple clients. A private\n                                # cache is usually the local cache where the request originated\n                                # whereas the shared cache is usually the caching proxy server.\n                                # The same formatting rules that apply to maxAge apply to this\n                                # option.\n      flags:                    # Set of caching directives\n        - no-cache              # A cache MUST NOT use the response to satisfy a subsequent\n                                # request without successful revalidation with the origin server.\n        - no-store              # A cache MUST NOT store any part of either the response or the\n                                # request that elicited it.\n        - must-revalidate       # A cache MUST NOT use the cached response after it has expired.\n                                # Because a cache can be configured to ignore cache expiration and\n                                # the client can specify the max-stale option, this flag provides\n                                # a mechanism to require revalidation of stale entries.\n        - proxy-revalidate      # Has the same meaning as must-revalidate, but only applies to\n                                # shared caches.\n        - no-transform          # An intermediate cache or proxy MUST NOT change the headers that\n                                # are subject to the no-transform directive or the response body\n                                # itself.\n                                # http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.5.2\n        - private               # Indicates that all or part of the response message is intended\n                                # for a single user and MUST NOT be cached by a shared cache.\n        - public                # Indicates that the response MAY be cached by any cache, even if\n                                # it would normally be non-cacheable or cacheable only within a\n                                # non-shared cache.\n                                 \n      private:                  # List of header fields in the response that are intended for a\n                                # single user and MUST NOT be cached by a shared cache. Setting\n                                # this option automatically sets the private flag.\n        - Authorization\n        \n      noCache:                  # List of header fields that MUST NOT be sent in the response to a\n                                # subsequent request without successful revalidation with the\n                                # origin server.\n        - Content-Type\n        \n      extensions:               # Custom cache-control directives.\n        bare:                   # With no or empty value, output is a bare directive\n        has-value: 17           # With a value, output is has-value=\"17\"\n```\n\n### Examples\n\n```yaml\n# Cache all resources (GET methods and resources with an explicit group) for 30 seconds.\n# DANGER: this may have unexpected consequences if the resource is not expecting caching to occur.\ncacheControl:\n    - maxAge: 30s\n```\n\n## Caching\n\nAfter setting the cache control options, an in-process response cache can be enabled, possibly\nbacked by an external store.\n\nThe local, in-process cache and the external store can be used independently of each other. For\nexample, with no local cache, the store will be queried for each request.\n\n```yaml\ncache:\n    # Optional. Configuration options for the local, in-memory cache. If no options are specified,\n    # no local response caching occurs.\n    local:\n        maximumSize: Size  # Maximum memory the local cache can consume.\n                           # Examples: 100MB, 10KB\n                           # Suffixes: B, KB, MB, GB, TB \n        expire: Duration   # Maximum amount of time to keep an item in the in-memory cache. This\n                           # may be longer or shorter than the maxAge for the response.\n          \n    # Optional. Configuration for remote, shared cache storage. For example, a memcached cluster.\n    # The local, in-memory cache is consulted first and, if not found, the store is queried.\n    store:\n        type: Type         # Type of storage. The type defines what other options are available.\n```\n\n### Memcached\n\nTo use a memcached cluster:\n\n1. Add the maven dependency:\n\n    ```xml\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.bazaarvoice.dropwizard\u003c/groupId\u003e\n        \u003cartifactId\u003edropwizard-caching-bundle-memcached\u003c/artifactId\u003e\n        \u003cversion\u003e${dropwizard-caching-bundle.version}\u003c/version\u003e\n    \u003c/dependency\u003e\n    ```\n\n2. Configure memcached\n\n    ```yaml\n    cache:\n        store:\n            type: memcached\n            servers:             # List of memcached server host or ip address and port\n                - localhost:11211\n            keyPrefix: String    # Prefix to add to all cache keys.\n            readOnly: Boolean    # True to only read from the cache, but not update. Default false.\n    ```\n\n#### Memcached Requirements\n\nThe memcached server must support the memcached binary protocol.\n\n#### Keys\n\nMemcached limits keys to 250 bytes. If the key is longer than 250 bytes, the memcached store will\nhash the original key, truncate the key, and append the hash.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazaarvoice%2Fdropwizard-caching-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbazaarvoice%2Fdropwizard-caching-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazaarvoice%2Fdropwizard-caching-bundle/lists"}