# Proxy\_cache\_key and $content\_length

**URL:** <https://www.ruby-forum.com/t/proxy-cache-key-and-content-length/227957>\
**Category:** NGINX\
**Created:** [April 4, 2013, 2:00pm UTC](https://www.ruby-forum.com/t/proxy-cache-key-and-content-length/227957 "2013-04-04T14:00:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/839c29/32.png) [@ntib1](https://www.ruby-forum.com/u/ntib1)\
**Post date:** [April 4, 2013, 2:00pm UTC](https://www.ruby-forum.com/t/proxy-cache-key-and-content-length/227957/1 "2013-04-04T14:00:04Z")

</div>

Hi,

I’d like to put $content\_length in proxy\_cache\_key in order nginx to  
check  
if file had changed and send it instead of old file if it’s case.

But the $content\_length is always empty. Why ?

Or do you have another solution for my problem ?

Thanks,

Thibaut

Posted at Nginx Forum:

> **[proxy\_cache\_key and $content\_length](https://forum.nginx.org/read.php?2,238097,238097#msg-238097)**
>
> Hi, I'd like to put $content\_length in proxy\_cache\_key in order nginx to check if file had changed and send it instead of old file if it's case. But the $content\_length is always empty. Why ? Or do you have another solution for my problem ?

---

<div class="post-metadata">

**Author:** ![ntib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/839c29/32.png) [@ntib1](https://www.ruby-forum.com/u/ntib1)\
**Post date:** [April 4, 2013, 2:11pm UTC](https://www.ruby-forum.com/t/proxy-cache-key-and-content-length/227957/2 "2013-04-04T14:11:10Z")

</div>

Hi  
That’s a good idea but I think it’s not possible  
The key is set before request is sent to backend but it can only know  
the content length after the request is sent to backend (catch 22)

---

<div class="post-metadata">

**Author:** ![ntib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/839c29/32.png) [@ntib1](https://www.ruby-forum.com/u/ntib1)\
**Post date:** [April 4, 2013, 2:53pm UTC](https://www.ruby-forum.com/t/proxy-cache-key-and-content-length/227957/3 "2013-04-04T14:53:16Z")

</div>

Ok, it’s what I supposed but I was not sure.  
Is there an alternative ?

Posted at Nginx Forum:

> **[Re: proxy\_cache\_key and $content\_length](https://forum.nginx.org/read.php?2,238097,238104#msg-238104)**
>
> Hi, I'd like to put $content\_length in proxy\_cache\_key in order nginx to check if file had changed and send it instead of old file if it's case. But the $content\_length is always empty. Why ? Or do you have another solution for my problem ?
