# How to set the minimum size of the cache file

**URL:** <https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593>\
**Category:** NGINX\
**Created:** [September 16, 2009, 7:21am UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593 "2009-09-16T07:21:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [September 16, 2009, 7:21am UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/1 "2009-09-16T07:21:25Z")

</div>

Hi,

How to set the minimum size of the cache file ?

2009-09-16

Chancey

---

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [September 16, 2009, 11:22am UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/2 "2009-09-16T11:22:33Z")

</div>

On Wed, Sep 16, 2009 at 01:07:05PM +0800, Chancey wrote:

> How to set the minimum size of the cache file ?

Currently there is no way.  
Could you tell why do you want to set this limit ?

---

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [September 16, 2009, 12:05pm UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/3 "2009-09-16T12:05:17Z")

</div>

Back-end to provide search suggest services .

Example:

Two request url:  
a . [http://xxx/a?q=a](http://xxx/a?q=a)  
b . [http://xxx/a?q=b](http://xxx/a?q=b)

Response results :  
a. xxxxxxxxxx  
b. null

The results of a need to be cached , b don’t need.  
Because there are a large number of fruitless requests , If b is the  
cache will appear the following situations :

1 . Caching a lot of useless information, resulting in a waste of disk  
space  
2 . Very high Disk IO load cause the system to slow

Search services have their own caching mechanism , but I would like to  
omit the PHP parsing process, will get better performance

Sorry,my english is so poor that i don’t know whether a clear  
expression.

2009-09-16

Chancey

å‘ä»¶äººï¼š Igor S.  
å‘é€æ—¶é—´ï¼š 2009-09-16 17:15:32  
æ”¶ä»¶äººï¼š nginx  
æŠ„é€ï¼š  
ä¸»é¢˜ï¼š Re: How to set the minimum size of the cache file

On Wed, Sep 16, 2009 at 01:07:05PM +0800, Chancey wrote:

> How to set the minimum size of the cache file ?  
> Currently there is no way.  
> Could you tell why do you want to set this limit ?  
> –  
> Igor S.  
> [Igor Sysoev](http://sysoev.ru/en/)

---

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [September 16, 2009, 4:07pm UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/4 "2009-09-16T16:07:03Z")

</div>

It’s a good idea, I have set it successful.

Thank you very much!

2009-09-16

Chancey

å‘ä»¶äººï¼š MirosÅ‚aw Jaworski  
å‘é€æ—¶é—´ï¼š 2009-09-16 18:41:17  
æ”¶ä»¶äººï¼š nginx  
æŠ„é€ï¼š  
ä¸»é¢˜ï¼š Re: Re: How to set the minimum size of the cache file

On Wed, 2009-09-16 at 17:56 +0800, Chancey wrote:

> a. xxxxxxxxxx  
> b. null
> 
> The results of a need to be cached , b don’t need.  
> You can run nginx without caching enforcement ( don’t use  
> proxy\_cache\_valid ) and modify(_) “search suggest service” so it will  
> return headers allowing caching for responses other that null.  
> (_) very likely modification is adding single line of code setting  
> “Expire:” header before returning result.

–  
MirosÅ‚aw “Psyborg” Jaworski  
GCS/IT d- s+:+ a C++$ UBI++++$ P+++$ L- E— W++(+++)$ N++ o+ K- w-- O-  
M- V- PS+ PE++ Y+ PGP t 5? X+ R++ !tv b++(+++) DI++ D+ G e\* h++ r+++ y?  
“Never let your sense of morals get in the way of doing what’s  
right.”

---

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [September 16, 2009, 12:45pm UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/5 "2009-09-16T12:45:41Z")

</div>

On Wed, 2009-09-16 at 17:56 +0800, Chancey wrote:

> a. xxxxxxxxxx  
> b. null
> 
> The results of a need to be cached , b don’t need.

You can run nginx without caching enforcement ( don’t use  
proxy\_cache\_valid ) and modify(\*) “search suggest service” so it will  
return headers allowing caching for responses other that null.

(\*) very likely modification is adding single line of code setting  
“Expire:” header before returning result.

---

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [April 13, 2010, 11:18am UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/6 "2010-04-13T11:18:28Z")

</div>

Igor S. wrote:

> On Wed, Sep 16, 2009 at 01:07:05PM +0800, Chancey wrote:
> 
> > How to set the minimum size of the cache file ?
> 
> Currently there is no way.  
> Could you tell why do you want to set this limit ?

Hi Igor,  
I have the same question.  
nginx is my reverse proxy cache servers, web page nginx cached was  
generated by backend php program, sometime when php fetch data from db  
server failed, it will generate the wrong page.  
the wrong page’s size always much smaller than the right page. if I can  
set the minimum size of the cache file, nginx will not cache the wrong  
page.

thaks a lot.

```
                 yangchunyu

```

---

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [April 13, 2010, 2:48pm UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/7 "2010-04-13T14:48:03Z")

</div>

On Tue, Apr 13, 2010 at 4:18 AM, Yahwist Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> page.
> 
> thaks a lot.
> 
> Â Â Â Â Â Â Â Â Â Â yangchunyu

If something went wrong, shouldn’t your PHP be generating a 40x or 50x  
error code? Nginx doesn’t cache these by default.

## A third-party web application which returns a 20X code on errors is currently the bane of my existence. It just plain stinks for monitoring, log analysis, and just about anything else. If you have any influence over the back-end PHP code at all, I would change it to return proper error codes.

RPM

---

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [April 13, 2010, 2:44pm UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/8 "2010-04-13T14:44:32Z")

</div>

On Tue, Apr 13, 2010 at 4:18 AM, Yahwist Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> page.
> 
> thaks a lot.
> 
> Â Â Â Â Â Â Â Â Â Â yangchunyu

If something went wrong, shouldn’t your PHP be generating a 50x error  
code? Nginx doesn’t cache these by default.

## A webapplications that returns a 20X code on error are the bane of my existence at the moment. Do you control the back-end PHP code at all?

RPM

---

<div class="post-metadata">

**Author:** ![Chancey](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ec9cab/32.png) [@Chancey](https://www.ruby-forum.com/u/Chancey)\
**Post date:** [April 14, 2010, 1:03pm UTC](https://www.ruby-forum.com/t/how-to-set-the-minimum-size-of-the-cache-file/175593/9 "2010-04-14T13:03:03Z")

</div>

Ryan M. wrote:

> On Tue, Apr 13, 2010 at 4:18 AM, Yahwist Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > page.
> > 
> > thaks a lot.
> > 
> > Â Â Â Â Â Â Â Â Â Â yangchunyu
> 
> If something went wrong, shouldn’t your PHP be generating a 50x error  
> code? Nginx doesn’t cache these by default.
> 
> ## A webapplications that returns a 20X code on error are the bane of my existence at the moment. Do you control the back-end PHP code at all?
> 
> RPM

I have forwarded your good solutions to our programmer.  
the wrong page never be cached.

thanks a lot

```
         yangchunyu

```
