# Reverse proxy\_

**URL:** <https://www.ruby-forum.com/t/reverse-proxy/183562>\
**Category:** NGINX\
**Created:** [February 16, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/reverse-proxy/183562 "2010-02-16T16:26:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fredrik\_Widlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/278dde/32.png) [@Fredrik\_Widlund](https://www.ruby-forum.com/u/Fredrik_Widlund)\
**Post date:** [February 16, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/reverse-proxy/183562/1 "2010-02-16T16:26:17Z")

</div>

Hi,

I am setting up a reverse-proxy system with Nginx (0.8.32) both as  
back-end and proxy. The system is used for delivering static large  
files.

What I would like to achieve is caching the files on the proxies as long  
as possible offloading the back-end. I would also like the proxy to  
react to changes on the back-end, but without retransmitting already  
cached unmodified content.

My problem is that I’m not able to get the proxy to revalidate  
unmodified static content without retransmitting the already cached  
file. E.g. if I set proxy\_cache\_valid for 200/OK delivered content to 60  
minutes the proxy won’t react to changes in the back-end for that period  
of time, and if I set it to 1 minute the file will be retransmitted from  
back-end to proxy every minute, if requested from the proxy by a client.  
What I would like is, for example, for the proxy to revalidate cached  
content with I-M-S set to the time of the content being cached and if  
not modified refreshing the validity of the previously cached content  
and returning it to the client.

I’ve looked through the documentation and played with cache-control  
directives like for example pre/post-check without succeeding in  
creating this behaviour. There probably is an obvious answer to this  
question, only I haven’t been able to find it.

Kind regards,  
Fredrik Widlund

---

<div class="post-metadata">

**Author:** ![Fredrik\_Widlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/278dde/32.png) [@Fredrik\_Widlund](https://www.ruby-forum.com/u/Fredrik_Widlund)\
**Post date:** [February 16, 2010, 4:59pm UTC](https://www.ruby-forum.com/t/reverse-proxy/183562/2 "2010-02-16T16:59:04Z")

</div>

Hello!

On Tue, Feb 16, 2010 at 04:25:21PM +0100, Fredrik Widlund wrote:

> retransmitting already cached unmodified content.  
> and if not modified refreshing the validity of the previously  
> cached content and returning it to the client.
> 
> I’ve looked through the documentation and played with  
> cache-control directives like for example pre/post-check without  
> succeeding in creating this behaviour. There probably is an  
> obvious answer to this question, only I haven’t been able to  
> find it.

It’s not currently supported.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Fredrik\_Widlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/278dde/32.png) [@Fredrik\_Widlund](https://www.ruby-forum.com/u/Fredrik_Widlund)\
**Post date:** [February 16, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/reverse-proxy/183562/3 "2010-02-16T17:07:51Z")

</div>

Hi Maxim,

Thanks for the answer! Are there currently any plans to add support for  
this in the near future?

Kind regards,  
Fredrik Widlund

-----Ursprungligt meddelande-----  
Från: Maxim D. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Skickat: den 16 februari 2010 16:58  
Till: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Ämne: Re: reverse proxy\_

Hello!

On Tue, Feb 16, 2010 at 04:25:21PM +0100, Fredrik Widlund wrote:

> retransmitting already cached unmodified content.  
> and if not modified refreshing the validity of the previously  
> cached content and returning it to the client.
> 
> I’ve looked through the documentation and played with  
> cache-control directives like for example pre/post-check without  
> succeeding in creating this behaviour. There probably is an  
> obvious answer to this question, only I haven’t been able to  
> find it.

It’s not currently supported.

Maxim D.

* * *

nginx mailing list  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> **[mailman.nginx.org archive](http://mailman.nginx.org/pipermail/)**

---

<div class="post-metadata">

**Author:** ![Fredrik\_Widlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/278dde/32.png) [@Fredrik\_Widlund](https://www.ruby-forum.com/u/Fredrik_Widlund)\
**Post date:** [February 24, 2010, 10:20am UTC](https://www.ruby-forum.com/t/reverse-proxy/183562/4 "2010-02-24T10:20:56Z")

</div>

Hi,

Explicitly purging the cache would not work in this scenario though.

Why is this not doable? I’m even considering adding support for this  
myself into Nginx, since we really need it and also since it seemed kind  
of natural?

This could of course be an optional feature, but it would be interesting  
to know what this breaks?

Regards,  
Fredrik

---

<div class="post-metadata">

**Author:** ![Fredrik\_Widlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/278dde/32.png) [@Fredrik\_Widlund](https://www.ruby-forum.com/u/Fredrik_Widlund)\
**Post date:** [February 25, 2010, 7:51pm UTC](https://www.ruby-forum.com/t/reverse-proxy/183562/5 "2010-02-25T19:51:36Z")

</div>

On Wed, Feb 24, 2010 at 3:20 AM, Fredrik Widlund  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Why is this not doable? I’m even considering adding support for this myself into Nginx, since we really need it and also since it seemed kind of natural?
> 
> This could of course be an optional feature, but it would be interesting to know what this breaks?

I agree… this shouldn’t be impossible by any stretch. Squid seems to  
handle this scenrio just fine, and the Cache-Control infrastructure of  
HTTP/1.1 was designed explicitly to enable this behavior.

## What is the scnario that doesn’t work for this?

RPM

---

<div class="post-metadata">

**Author:** ![Fredrik\_Widlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/278dde/32.png) [@Fredrik\_Widlund](https://www.ruby-forum.com/u/Fredrik_Widlund)\
**Post date:** [February 24, 2010, 2:36am UTC](https://www.ruby-forum.com/t/reverse-proxy/183562/6 "2010-02-24T02:36:17Z")

</div>

On Tue, Feb 16, 2010 at 8:07 AM, Fredrik Widlund  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi Maxim,
> 
> Thanks for the answer! Are there currently any plans to add support for this in the near future?
> 
> Kind regards,  
> Fredrik Widlund

It’s not really doable as far as I understand things, at least not in  
a general, portable way that satisfies all backends.

What you CAN do is you use ngx\_cache\_purge to have the backend inform  
nginx when content has changed. This is the only method that is  
general enough for any backend, but it of course requires you to do  
something.

> **[FRiCKLE Labs / nginx / cache\_purge](http://labs.frickle.com/nginx_cache_purge)**

Good luck.

– Merlin

---

<div class="post-metadata">

**Author:** ![Fredrik\_Widlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/278dde/32.png) [@Fredrik\_Widlund](https://www.ruby-forum.com/u/Fredrik_Widlund)\
**Post date:** [March 2, 2010, 11:17am UTC](https://www.ruby-forum.com/t/reverse-proxy/183562/7 "2010-03-02T11:17:39Z")

</div>

Hi Merlin,

Could you elaborate a bit around the problems with achieving this in a  
general way? It would be valuable to know before one tries to solve the  
problem as good as is possible.

Kind regards,  
Fredrik Widlund
