Allow requests to force cache to revalidate #238
                
     Closed
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This PR provides a mechanism for "revalidating" cache contents on a per-request basis. When a request contains the
x-apicache-revalidateheader, we skip loading from the cache (similar to a cache "bypass") but still make the response cacheable in order to update the cache store with fresh content.I've found this to be useful in cases that would otherwise require manually clearing the cache before sending a new request in order to allow fresh content to be stored. In particular, I am implementing a "stale-while-revalidate" caching strategy in my application which serves stale content while revalidating in the background when the cached response is close to expiry, so that subsequent requests will receive more up-to-date content without having to incur the full processing overhead before sending a response to the client.
Note: I realized after-the-fact that this essentially duplicates the functionality from #220, which restored the original behavior for
x-apicache-force-fetchwhich was regressed in #65. I personally findrevalidateto be a more explicit description for the command (and less likely to be confused withbypass), but would be just as happy to see #220 merged in to restore this feature.