# Proxy\_cache doesn't return headers

**URL:** <https://www.ruby-forum.com/t/proxy-cache-doesnt-return-headers/204012>\
**Category:** NGINX\
**Created:** [March 3, 2011, 11:25am UTC](https://www.ruby-forum.com/t/proxy-cache-doesnt-return-headers/204012 "2011-03-03T11:25:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 3, 2011, 11:25am UTC](https://www.ruby-forum.com/t/proxy-cache-doesnt-return-headers/204012/1 "2011-03-03T11:25:44Z")

</div>

Hello,

We have quite busy phpbb based forum. I found that it is quite heavy  
loaded with bots(Google, AdSense, Yahoo. It seems that AdSense bot  
duplicate every user’s request). I have added confuguration to cache all  
dynamic requests and return them to bots only(see config below). But I  
faced strange issue, when page returned from cache - nginx doesn’t pass  
any headers back.

So questions are:

- Are there anything bad that response considered as http 0.9?
- Is it possible configure it to return headers in case when page was  
returned from cache so response will be considered as 1.1?
- It seems that cache refreshed evertime when page was hit by user(not  
bot). Is it possible to configure it not to refresh it till it is  
valid(72h in config). To not produce not necessary IO.

Here is how it looks in logs  
{{{  
66.249.66.89 - - [03/Mar/2011:12:02:51 +0200] “GET  
/viewtopic.php?f=112&t=73799&p=2363346 HTTP/1.1” 009 175820 “-”  
“Mediapartners-Google”  
}}}

Here is how response looks in wget -d  
–user-agent=“Mediapartners-Google”…  
{{{  
HTTP request sent, awaiting response…  
—response begin—  
—response end—  
200 No headers, assuming HTTP/0.9  
Length: unspecified  
Saving to: `index.php.3’  
}}}

Config sample

{{{

```
    set $crawlernocache 1;
    if ($http_user_agent ~ ".*Google.*"){
     set $crawlernocache 0;
    }

    if ($http_user_agent ~ ".*Yandex.*"){
     set $crawlernocache 0;
    }

  ...

          location / {
            proxy_pass http://127.0.0.1:80;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_set_header X-Forwarded-For

```

$proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header Accept-Encoding “”;  
proxy\_send\_timeout 300;  
set $delimeter +;  
proxy\_ignore\_headers “Expires” “X-Accel-Expires”  
“Cache-Control”;  
proxy\_cache\_bypass $crawlernocache;  
proxy\_cache crawlercache;  
proxy\_cache\_key  
$host$uri$arg\_f$delimeter$arg\_t$delimeter$arg\_start$delimeter$arg\_p;  
proxy\_cache\_valid 200 72h;  
}

}}}

Posted at Nginx Forum:

> **[proxy\_cache doesn't return headers](https://forum.nginx.org/read.php?2,179904,179904#msg-179904)**
>
> Hello, We have quite busy phpbb based forum. I found that it is quite heavy loaded with bots(Google, AdSense, Yahoo. It seems that AdSense bot duplicate every user's request). I have added confuguration to cache all dynamic requests and return them...

---

<div class="post-metadata">

**Author:** ![Alexander\_Zuban](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3bc359/32.png) [@Alexander\_Zuban](https://www.ruby-forum.com/u/Alexander_Zuban)\
**Post date:** [March 3, 2011, 12:10pm UTC](https://www.ruby-forum.com/t/proxy-cache-doesnt-return-headers/204012/2 "2011-03-03T12:10:52Z")

</div>

Hello!

On Thu, Mar 03, 2011 at 05:23:45AM -0500, Alexander Zuban wrote:

> - Are there anything bad that response considered as http 0.9?
> - Is it possible configure it to return headers in case when page was  
> returned from cache so response will be considered as 1.1?
> - It seems that cache refreshed evertime when page was hit by user(not  
> bot). Is it possible to configure it not to refresh it till it is  
> valid(72h in config). To not produce not necessary IO.

[…]

> ```
> proxy_cache_bypass $crawlernocache;
> 
> ```

You are using proxy\_cache\_bypass without identical proxy\_no\_cache,  
it’s known to have problems (and that’s why you see http 0.9  
replies). You have to write something like

```
              proxy_cache_bypass $crawlernocache;
              proxy_no_cache $crawlernocache;

```

instead. This way a) http 0.9 problem will be fixed and b) normal  
users hits won’t touch cache at all.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Alexander\_Zuban](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3bc359/32.png) [@Alexander\_Zuban](https://www.ruby-forum.com/u/Alexander_Zuban)\
**Post date:** [March 3, 2011, 1:00pm UTC](https://www.ruby-forum.com/t/proxy-cache-doesnt-return-headers/204012/3 "2011-03-03T13:00:22Z")

</div>

Maxim thank you!

You are right, this was what I did also(and seemsit start to return  
headers). Seems it will be simpler to prefetch recent pages in cache  
during the night .

Regards,  
Alexander

Posted at Nginx Forum:

> **[Re: proxy\_cache doesn't return headers](https://forum.nginx.org/read.php?2,179904,179929#msg-179929)**
>
> Hello, We have quite busy phpbb based forum. I found that it is quite heavy loaded with bots(Google, AdSense, Yahoo. It seems that AdSense bot duplicate every user's request). I have added confuguration to cache all dynamic requests and return them...
