We use nginx as reserve proxy server and want use proxy_cache to replace squid. There are apache servers behind nginx, we use deflate module to compress text/html pages. The problem is if proxy_cache has cached the compressed page but the client side that request page does not support uncompress, the page can not be see correctly. I know squid using http header Accept-Encoding to store different cache file, but there is no way to use it in nginx proxy_cache_key. Thanks yahwist
help about how proxy_cache to store differet cache file by http header vary Accept-Encoding like squ
on 2010-03-03 18:20
Re: help about how proxy_cache to store differet cache file by http header vary Accept-Encoding like
on 2010-03-03 19:25
On Thu, 2010-03-04 at 01:19 +0800, yangchunyu wrote: > We use nginx as reserve proxy server and want use proxy_cache to replace squid. > There are apache servers behind nginx, we use deflate module to compress text/html pages. > The problem is if proxy_cache has cached the compressed page but the client side that request page does not support uncompress, the page can not be see correctly. > I know squid using http header Accept-Encoding to store different cache file, but there is no way to use it in nginx proxy_cache_key. You can try to use proxy_cache_key to define caching key ( i don't know however if you find variable that will do trick ). The other method i would think of is not letting nginx to cache compressed content. And i don't mean caching or not depend on whether backend response is compressed or not - i mean forcing uncompressed transmission between nginx and backends. You may even gain another benefit - lessen the compression burden on backends which may give you spare cpu cycles on them. I believe proxy_set_header Accept-Encoding ""; in proxying location is the way to go. -- Miroslaw "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?
on 2010-03-05 08:24
I think use proxy_cache_key to define caching key is good idea .
but I do not know which variable to use that can distinguish client side
support compressed or compressed content and store the different cache
file.
Can Igor Sysoev help me . Thanks a lot.
yangchunyu
-----ÓʼþÔ¼þ-----
·¢¼þÈË: Miros?aw Jaworski [mailto:mjaw@ikp.pl]
·¢ËÍʱ¼ä: 2010Äê3ÔÂ4ÈÕ 2:25
ÊÕ¼þÈË: nginx@nginx.org
Ö÷Ìâ: Re: help about how proxy_cache to store differet cache file by
httpheader vary Accept-Encoding like squid
On Thu, 2010-03-04 at 01:19 +0800, yangchunyu wrote:
> We use nginx as reserve proxy server and want use proxy_cache to replace
squid.
> There are apache servers behind nginx, we use deflate module to compress
text/html pages.
> The problem is if proxy_cache has cached the compressed page but the
client side that request page does not support uncompress, the page can
not
be see correctly.
> I know squid using http header Accept-Encoding to store different cache
file, but there is no way to use it in nginx proxy_cache_key.
You can try to use proxy_cache_key to define caching key ( i don't
know however if you find variable that will do trick ).
The other method i would think of is not letting nginx to cache
compressed content. And i don't mean caching or not depend on
whether backend response is compressed or not - i mean forcing
uncompressed transmission between nginx and backends.
You may even gain another benefit - lessen the compression burden
on backends which may give you spare cpu cycles on them.
I believe
proxy_set_header Accept-Encoding "";
in proxying location is the way to go.
--
Miroslaw "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?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
on 2010-03-12 06:10
2010/3/5 æ¨æ˜¥å®‡ <yangchunyu@soufun.com>: > I think use proxy_cache_key to define caching key is good idea . > but I do not know which variable to use that can distinguish client side > support compressed or compressed content and store the different cache file. Here's an example I've used. Of course the upstream server must return compressed responses to HTTP/1.0 requests, which many do not by default: ================= #normalize all accept-encoding headers to just gzip or the empty string set $myae ""; if ($http_accept_encoding ~* gzip) { set $myae "gzip"; } #the following prevents comressed responses from backend proxy_set_header Accept-Encoding $myae; proxy_pass http://backend; #the following uses a combination of URI and the accept-encoding as a proxy cache key proxy_cache_key "$host$request_uri$myae"; -- RPM
on 2010-03-12 14:39
Thanks a lot, This solution is good
Thanks again!
yahwist
-----邮件原件-----
å‘件人: Ryan Malayter [mailto:malayter@gmail.com]
å‘逿—¶é—´: 2010å¹´3月12æ—¥ 13:10
收件人: nginx@nginx.org
主题: Re: help about how proxy_cache to store differet cache file by
httpheader vary Accept-Encoding like squid
2010/3/5 î´º <yangchunyu@soufun.com>:
> I think use proxy_cache_key to define caching key is good idea .
> but I do not know which variable to use that can distinguish client side
> support compressed or compressed content and store the different cache file.
Here's an example I've used. Of course the upstream server must return
compressed responses to HTTP/1.0 requests, which many do not by
default:
=================
#normalize all accept-encoding headers to just gzip or the empty string
set $myae "";
if ($http_accept_encoding ~* gzip) {
set $myae "gzip";
}
#the following prevents comressed responses from backend
proxy_set_header Accept-Encoding $myae;
proxy_pass http://backend;
#the following uses a combination of URI and the accept-encoding as a
proxy cache key
proxy_cache_key "$host$request_uri$myae";
--
RPM
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
on 2010-03-12 17:08
You can also make the if block more complicated to remove accept-encoding for types you know will not be compressed (.gif, .png, .mpg, etc) On Fri, Mar 12, 2010 at 7:38 AM, æ¨æ˜¥å®‡ <yangchunyu@soufun.com> wrote: > å‘逿—¶é—´: 2010å¹´3月12æ—¥ 13:10 > compressed responses to HTTP/1.0 requests, which many do not by > #the following uses a combination of URI and the accept-encoding as a > > _______________________________________________ > nginx mailing list > nginx@nginx.org > http://nginx.org/mailman/listinfo/nginx > -- RPM
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.