# If statement for Content-Length

**URL:** <https://www.ruby-forum.com/t/if-statement-for-content-length/182589>\
**Category:** NGINX\
**Created:** [January 30, 2010, 1:49pm UTC](https://www.ruby-forum.com/t/if-statement-for-content-length/182589 "2010-01-30T13:49:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [January 30, 2010, 1:49pm UTC](https://www.ruby-forum.com/t/if-statement-for-content-length/182589/1 "2010-01-30T13:49:17Z")

</div>

Hi Guys,

I’ve been trying to work out if this can be done or not with not much  
luck

I want to see if I can do something like this

If (Content-Length \< 1024){  
Return 403;  
}

Im guessing this can’t be done, however it would get around a caching  
issue I am having with large files.

Kingsley

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [January 30, 2010, 4:26pm UTC](https://www.ruby-forum.com/t/if-statement-for-content-length/182589/2 "2010-01-30T16:26:42Z")

</div>

2010/1/30 Kingsley F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> Im guessing this can’t be done, however it would get around a caching issue I am having with large files.

what is the caching issue you’re having with large files ?

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [January 30, 2010, 10:56pm UTC](https://www.ruby-forum.com/t/if-statement-for-content-length/182589/3 "2010-01-30T22:56:26Z")

</div>

Mainly I just don’t want to cache them,

The site is hit by a massive amount of small files and some larger, due  
to the setup I can’t separate them (customers are involved). So I want  
to be able to only cache files under say 5-10mb and just let everything  
else proxy\_pass normally.

Kingsley

---

<div class="post-metadata">

**Author:** ![Kingsley\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cab0a1/32.png) [@Kingsley\_F](https://www.ruby-forum.com/u/Kingsley_F)\
**Post date:** [February 2, 2010, 2:32am UTC](https://www.ruby-forum.com/t/if-statement-for-content-length/182589/4 "2010-02-02T02:32:40Z")

</div>

On Sat, Jan 30, 2010 at 8:47 PM, Kingsley F.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to see if I can do something like this
> 
> If (Content-Length \< 1024){  
> Return 403;  
> }

Use the “client\_max\_body\_size” directive for it:

```
client_max_body_size 1k;

```

See [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpCoreModule#client_max_body_size)

Cheers,  
-agentzh
