# Caching REST API

**URL:** https://discourse.mitmproxy.org/t/caching-rest-api/42
**Category:** Uncategorized
**Created:** [June 9, 2016, 5:58pm UTC](https://discourse.mitmproxy.org/t/caching-rest-api/42 "2016-06-09T17:58:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Maxime](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/maxime/32/28_2.png) [@Maxime](https://discourse.mitmproxy.org/u/Maxime)
#### Post date: [June 9, 2016, 5:58pm UTC](https://discourse.mitmproxy.org/t/caching-rest-api/42/1 "2016-06-09T17:58:37Z")

</div>

I’m using mitmproxy as a transparent proxy with a white list. This allows me to restrict the access to some API on the internet.

The access to the API I’m using can be a bit slow (1-2 seconds), so I’ve added a cache to directly reply the last response for the same tuple (path, content, headers). This seems to work but it’s still too slow (~1 second). I’ve added some logs and it looks like most of the time is spent between the client connection and the call to the clientconnect of my script.

I’m guessing that mitmproxy is building a certificate, is that right? Could I simply put it into a cache too?

---

<div class="post-metadata">

### Author: ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)
#### Post date: [June 10, 2016, 10:42pm UTC](https://discourse.mitmproxy.org/t/caching-rest-api/42/2 "2016-06-10T22:42:33Z")

</div>

Hi @Maxime,

My first guess would be that mitmproxy is still connecting to the upstream server to get the certificate information. If the client sends a TLS Server Name Indication, you can just pass `--no-upstream-cert` to mitmproxy and things should be considerably faster. Does this solve your problem?

---

<div class="post-metadata">

### Author: ![Maxime](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/maxime/32/28_2.png) [@Maxime](https://discourse.mitmproxy.org/u/Maxime)
#### Post date: [June 10, 2016, 11:05pm UTC](https://discourse.mitmproxy.org/t/caching-rest-api/42/3 "2016-06-10T23:05:33Z")

</div>

I’ve added --no-upstream-cert to mitmdump but it doesn’t seem to be faster… Am I doing something wrong?

---

<div class="post-metadata">

### Author: ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)
#### Post date: [June 11, 2016, 8:49pm UTC](https://discourse.mitmproxy.org/t/caching-rest-api/42/4 "2016-06-11T20:49:34Z")

</div>

Hard to say - you may be successful by increasing the verbosity ( `-vvv` ) and see if there’s anything in the event log that gives away what the issue is.
