It feels to me like this function does way too many different things (and perhaps 3 level deep for loop is a smell which indicates this)

My main suggestion would be to separate the generation of the urls to purge with the actual sending of the purge requests, ie replace 
```
                resp = requests.request('PURGE', url, headers=headers)          
```
with
```
yield url
```
(This gives the benefit of actually being able to test that the purge worked, which we aren't at the moment.

Then, I think there must be a way of simplifying the triple nested loops, I'm thinking about that one :)