Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1384

Expose CacheInvalidator in CachingHttpClientBuilder

    XMLWordPrintableJSON

Details

    Description

      There is currently no way to customize the CacheInvalidator. Could it be possible to allow setting a CacheInvalidator in CachingHttpClientBuilder (eg. CachingHttpClientBuilder#setCacheInvalidator())

      Our use case :

      • HttpClientCache is used in a Caching Reverse Proxy (shared cache, exposed to public connections)
      • We have to ensure the cache cannot be flush by a random user.
      • The default CacheInvalidator flushes all variants of an URI when receiving anything other than GET, HEAD (compliant with RFC)
      • It is currently possible for a user to flush the whole cache by sending POST requests of all uri (this may be harmful even only on a home page).

      While it is not RFC-compliant, we need at least the ability to prevent invalidation in CacheInvalidator#flushInvalidatedCacheEntriesFor and/or control invalidation with custom method (PURGE) and other criteria (like remote ip)

      The same applies to HttpClientCache 4.2.5: CachingHttpClient which does not allow provide a custom CacheInvalidator

      Would this sound ok for you ?

      Attachments

        1. httpclient-patch.txt
          14 kB
          Nicolas Richeton
        2. patch.txt
          7 kB
          Nicolas Richeton

        Activity

          People

            olegk Oleg Kalnichevski
            nricheton Nicolas Richeton
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: