On Tue, Mar 13, 2012 at 4:08 PM, Greg Grensteiner <ggrensteiner@tvg.com> wrote:
>>> Does the srcache_store_max_size directive work for you?
>
>>http://wiki.nginx.org/HttpSRCacheModule#srcache_store_max_size
>
> No, this will not work. What I need is the size of the currently processing
> request that is being written to the cache. I need this value so I can
> compare it to the Content-Length header sent from my upstream app server.
> If the size of the request being sent to srcache_store matches the
> Content-Length from my app server then it's a valid result to send to the
> cache.
>
The srcache_store thing does not send the response data piece by
piece. It always buffers the whole response. So if it does not see the
(explicit) end of the output stream, it will just throw away the
buffered data and does not touch the cache at all.
Do you mean that your backend server can send extra data than the size
specified by its Content-Length response header?
>
>>>This wouldn't be an issue if the proxy_pass would throw an error/timeout
>>> if
>>> it get a short return, do you know of any way to do that?
>>>
>> I'm not sure what you're talking about here :)
>
> What I'm talking about is this
>
> http://nginx.2469901.n2.nabble.com/nginx-and-upstream-Content-Length-td6846934.html
>
> where proxy_pass doesn't throw an error if the Content-Length doesn't match
> the size of the return.
>
Okay, if ngx_proxy cannot detect the connection abortion errors here,
then ngx_srcache cannot know either. I think we should fix ngx_proxy
in the first place rather than doing work-around on the ngx_srcache
side.
But anyway, ngx_srcache can do a double-check on the data size if a
Content-Length response header is present. Do you have the tuits to
contribute a patch for ngx_srcache?
Thanks!
-agentzh