# Proxy\_cache seems not working with X-Accel-Redirect

**URL:** <https://www.ruby-forum.com/t/proxy-cache-seems-not-working-with-x-accel-redirect/236143>\
**Category:** NGINX\
**Created:** [August 9, 2013, 12:21pm UTC](https://www.ruby-forum.com/t/proxy-cache-seems-not-working-with-x-accel-redirect/236143 "2013-08-09T12:21:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [August 9, 2013, 12:21pm UTC](https://www.ruby-forum.com/t/proxy-cache-seems-not-working-with-x-accel-redirect/236143/1 "2013-08-09T12:21:07Z")

</div>

My config

location ~ /cached/ {  
proxy\_pass [http://apache](http://apache);  
proxy\_cache cache;  
proxy\_cache\_valid 2h;  
proxy\_cache\_key “$host|$request\_uri”;

}

location /htdocs\_internal/ {  
internal;

```
        alias $htdocs_path;

```

}

Requests with header in reply X-Accel-Redirect not cached, every time  
request is sent to apache. When i add these directives  
proxy\_pass\_header X-Accel-Redirect;  
proxy\_ignore\_headers X-Accel-Redirect;  
cache works fine (but is useless 🙂 ), so it isn’t problem with “no  
cache”  
headers from apache.

Posted at Nginx Forum:

> **[proxy\_cache seems not working with X-Accel-Redirect](https://forum.nginx.org/read.php?2,241734,241734#msg-241734)**
>
> My config location ~ /cached/ { proxy\_pass http://apache; proxy\_cache cache; proxy\_cache\_valid 2h; proxy\_cache\_key "$host|$request\_uri"; } location /htdocs\_int

---

<div class="post-metadata">

**Author:** ![gray](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5fc32e/32.png) [@gray](https://www.ruby-forum.com/u/gray)\
**Post date:** [August 17, 2013, 4:33am UTC](https://www.ruby-forum.com/t/proxy-cache-seems-not-working-with-x-accel-redirect/236143/2 "2013-08-17T04:33:59Z")

</div>

Hello!

On Fri, Aug 09, 2013 at 06:20:21AM -0400, gray wrote:

> location /htdocs\_internal/ {  
> headers from apache.  
> Yes, proxy\_cache can’t cache responses with X-Accel-Redirect.

As a workaround, you may use an additional proxy layer with  
proxy\_cache and proxy\_ignore\_headers X-Accel-Redirect +  
proxy\_pass\_headers X-Accel-Redirect.

–  
Maxim D.

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