oesmith / puffing-billy

A rewriting web proxy for testing interactions between your browser and external sites. Works with ruby + rspec.
MIT License
656 stars 170 forks source link

Add `cache_whitelist` config option #279

Closed xtrasimplicity closed 4 years ago

xtrasimplicity commented 4 years ago

Background

Currently, for a URL to be cacheable, it must have a cacheable HTTP response code and:

The problem with this is that sometimes you may want to force a whitelisted host to also be cacheable. For example, in one application I'm working on, I'd like to block all external requests using c.non_whitelisted_requests_disabled, but allow specific hosts to be cached so that I can use Puffing-Billy as I would VCR.

Logically, when using c.non_whitelisted_requests_disabled only whitelisted requests are enabled. Unfortunately, however, whitelisted URLs are never cached, so I have two options: 1) Set c.non_whitelisted_requests_disabled to false and cache all requests, OR 2) Abandon my plan to use Puffing-billy as I would VCR, and just stub requests manually.

Solution

xtrasimplicity commented 4 years ago

Hey, @ronwsmith - apologies for the ping, but just wanted to see if this is something that you'd be open to, or if there's another way you'd prefer this be handled? Thanks!

ronwsmith commented 4 years ago

@xtrasimplicity this change looks good to me. I'm thinking we need to soon change the variable names as it hurts my head thinking about this logic now :) May be a little over a week before I get this in.

ronwsmith commented 4 years ago

@xtrasimplicity released in v2.3.0

xtrasimplicity commented 4 years ago

Thanks, @ronwsmith!