# Proxy doesn't cache

**URL:** <https://www.ruby-forum.com/t/proxy-doesnt-cache/228849>\
**Category:** NGINX\
**Created:** [May 10, 2013, 5:14am UTC](https://www.ruby-forum.com/t/proxy-doesnt-cache/228849 "2013-05-10T05:14:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Xenon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecc23a/32.png) [@Stefan\_Xenon](https://www.ruby-forum.com/u/Stefan_Xenon)\
**Post date:** [May 10, 2013, 5:14am UTC](https://www.ruby-forum.com/t/proxy-doesnt-cache/228849/1 "2013-05-10T05:14:19Z")

</div>

Hi!  
I want to use nginx as a caching proxy in front of an OCSP responder.  
The OCSP requests are transmitted via HTTP POST.

Hence, I configured nginx as follows:

proxy\_cache\_path /tmp/nginx/cache levels=1:2 keys\_zone=my-cache:8m  
max\_size=1000m inactive=600m;  
server {  
server\_name localhost;  
location / {  
proxy\_pass [http://213.154.225.237:80](http://213.154.225.237:80); #[ocsp.cacert.org](http://ocsp.cacert.org)  
proxy\_cache my-cache;  
proxy\_cache\_methods POST;  
proxy\_cache\_key “$scheme$proxy\_host$uri$request\_body”;  
proxy\_ignore\_headers X-Accel-Expires Expires Cache-Control  
Set-Cookie;  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
}  
)

I can access the OCSP responder through nginx and responses are received  
as expected - no issue. The problem is that nginx doesn’t cache the  
responses. Note that OCSP nonces are _not_ being sent as part of the  
request. Using Wireshark and nginx’ debug log, I verified that all my  
requests are identical. How to configure nginx that it caches the  
responses?

Note, I use the following command for testing:  
openssl ocsp -issuer cacert.crt -no\_nonce -CAfile CAbundle.crt -url  
[http://localhost/](http://localhost/) -serial

Thanks a lot for your help!  
Stefan

---

<div class="post-metadata">

**Author:** ![Stefan\_Xenon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecc23a/32.png) [@Stefan\_Xenon](https://www.ruby-forum.com/u/Stefan_Xenon)\
**Post date:** [May 11, 2013, 4:56pm UTC](https://www.ruby-forum.com/t/proxy-doesnt-cache/228849/2 "2013-05-11T16:56:45Z")

</div>

Hello!

On Fri, May 10, 2013 at 11:13:42AM +0800, Stefan Xenon wrote:

> location / {  
> I can access the OCSP responder through nginx and responses are received  
> as expected - no issue. The problem is that nginx doesn’t cache the  
> responses. Note that OCSP nonces are _not_ being sent as part of the  
> request. Using Wireshark and nginx’ debug log, I verified that all my  
> requests are identical. How to configure nginx that it caches the responses?
> 
> Note, I use the following command for testing:  
> openssl ocsp -issuer cacert.crt -no\_nonce -CAfile CAbundle.crt -url  
> [http://localhost/](http://localhost/) -serial

You configuration doesn’t contain proxy\_cache\_valid (see  
[Module ngx\_http\_proxy\_module](http://nginx.org/r/proxy_cache_valid)), and in the same time via  
proxy\_ignore\_headers it ignores all headers which may be used to  
set response validity based on response headers. That is, no  
responses will be cached with the configuration above.

You probably want to add something like

proxy\_cache\_valid 200 1d;

to your configuration.

–  
Maxim D.

> **[nginx: donation](http://nginx.org/en/donation.html)**

---

<div class="post-metadata">

**Author:** ![Stefan\_Xenon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecc23a/32.png) [@Stefan\_Xenon](https://www.ruby-forum.com/u/Stefan_Xenon)\
**Post date:** [May 14, 2013, 2:52pm UTC](https://www.ruby-forum.com/t/proxy-doesnt-cache/228849/3 "2013-05-14T14:52:37Z")

</div>

Thanks a lot Maxim. This really solved my problem. 🙂

Stefan

Am 11.05.2013 22:55, schrieb Maxim D.:
