proxy cache key needs to include accept encoding as php does the gzip for phpbb3<br><br><div class="gmail_quote">On Mon, Aug 1, 2011 at 12:42 PM, Nicholas Sherlock <span dir="ltr"><<a href="mailto:n.sherlock@gmail.com">n.sherlock@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi everyone,<br>
<br>
I'm using gzip and proxy_cache together, proxying to an Apache backend.<br>
Some of my clients are complaining that they are getting gzipped content<br>
which their browser is displaying without un-gzipping it, presumably<br>
because they getting served gzipped content when their browser doesn't<br>
support it.<br>
<br>
I noticed that HTTP/1.0 clients are getting served gzipped content even<br>
though gzip_http_version is set to 1.1. That should never happen, right?<br>
I guess it is because a 1.1 client requested it first, and it got<br>
cached? Here's the log of an HTTP/1.0 client (wget) grabbing the resource:<br>
<br>
wget -d<br>
"<a href="http://www.chickensmoothie.com/Forum/style.php?id=9&lang=en&v=1312084157" target="_blank">http://www.chickensmoothie.<u></u>com/Forum/style.php?id=9&lang=<u></u>en&v=1312084157</a>"<br>

<br>
---request begin---<br>
GET /Forum/style.php?id=9&lang=en&<u></u>v=1312084157 HTTP/1.0<br>
User-Agent: Wget/1.12 (cygwin)<br>
Accept: */*<br>
Host:<a href="http://www.chickensmoothie.com" target="_blank">www.chickensmoothie.com</a><br>
Connection: Keep-Alive<br>
<br>
---response begin---<br>
HTTP/1.1 200 OK<br>
Server: nginx/1.0.4<br>
Date: Mon, 01 Aug 2011 00:23:27 GMT<br>
Content-Type: text/css; charset=UTF-8<br>
Connection: keep-alive<br>
X-Powered-By: PHP/5.3.5-1ubuntu7.2<br>
Expires: Wed, 09 Nov 2011 00:22:33 GMT<br>
Last-Modified: Sun, 31 Jul 2011 03:49:17 GMT<br>
Vary: Accept-Encoding<br>
Content-Encoding: gzip<br>
Content-Length: 15750<br>
<br>
---response end---<br>
200 OK<br>
Registered socket 3 for persistent reuse.<br>
URI content encoding = `UTF-8'<br>
Length: 15750 (15K) [text/css]<br>
Saving to: `style.php@id=9&lang=en&v=<u></u>1312084157.4'<br>
<br>
2011-08-01 12:22:35 (21.4 KB/s) -<br>
`style.php@id=9&lang=en&v=<u></u>1312084157.4' saved [15750/15750]<br>
<br>
<br>
Note that the backend isn't sending a gzipped response to Nginx:<br>
<br>
<br>
wget --header="Host:<a href="http://www.chickensmoothie.com" target="_blank">www.<u></u>chickensmoothie.com</a>" -d<br>
"<a href="http://localhost:8080/Forum/style.php?id=9&lang=en&v=1312084157" target="_blank">http://localhost:8080/Forum/<u></u>style.php?id=9&lang=en&v=<u></u>1312084157</a>"<br>
<br>
---request begin---<br>
GET /Forum/style.php?id=9&lang=en&<u></u>v=1312084157 HTTP/1.0<br>
User-Agent: Wget/1.12 (linux-gnu)<br>
Accept: */*<br>
Host:<a href="http://www.chickensmoothie.com" target="_blank">www.chickensmoothie.com</a><br>
Connection: Keep-Alive<br>
<br>
---response begin---<br>
HTTP/1.1 200 OK<br>
Date: Mon, 01 Aug 2011 00:32:28 GMT<br>
Server: Apache/2.2.17 (Ubuntu)<br>
X-Powered-By: PHP/5.3.5-1ubuntu7.2<br>
X-Accel-Expires: 600<br>
Expires: Wed, 09 Nov 2011 00:32:28 GMT<br>
Last-Modified: Sun, 31 Jul 2011 03:49:17 GMT<br>
Vary: Accept-Encoding<br>
Connection: close<br>
Content-Type: text/css; charset=UTF-8<br>
<br>
---response end---<br>
200 OK<br>
Length: unspecified [text/css]<br>
Saving to: `style.php?id=9&lang=en&v=<u></u>1312084157.5'<br>
<br>
2011-08-01 00:32:28 (377 MB/s) - `style.php?id=9&lang=en&v=<u></u>1312084157.5'<br>
saved [78125]<br>
<br>
<br>
Here's my config details:<br>
<br>
nginx: nginx version: nginx/1.0.4<br>
<br>
gzip on;<br>
gzip_disable "MSIE [1-6]\.(?!.*SV1)";<br>
gzip_buffers 16 4k;<br>
gzip_types text/plain text/html text/css application/json<br>
application/x-javascript text/xml application/xml application/xml+rss<br>
text/javascript;<br>
gzip_vary on;<br>
gzip_http_version 1.1;<br>
<br>
proxy_temp_path /caches/proxy_temp;<br>
proxy_cache_path /caches/nginx levels=1:2 keys_zone=one:50m inactive=3d<br>
max_size=10g;<br>
<br>
server {<br>
        listen 80 default;<br>
        server_name _;<br>
<br>
        index index.php index.html index.htm;<br>
<br>
        location /Forum/style.php {<br>
                proxy_passhttp://<a href="http://127.0.0.1:8080" target="_blank">127.0.0.1:<u></u>8080</a>;<br>
                proxy_redirect off;<br>
                proxy_set_header X-Real-IP $remote_addr;<br>
                proxy_set_header Host $host;<br>
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>
                proxy_read_timeout 600;<br>
                proxy_intercept_errors on;<br>
<br>
                proxy_cache one;<br>
                proxy_cache_key $host$request_uri;<br>
                proxy_cache_valid 200 301 302 2000m;<br>
                proxy_cache_use_stale error timeout invalid_header updating;<br>
        }<br>
}<br>
<br>
I've disabled the proxy_cache for the moment, which seems to fix this<br>
behaviour (HTTP/1.0 clients get a plain response, HTTP/1.1 clients who<br>
send an accept-encoding:gzip get a gzipped response).<br>
<br>
Cheers,<br>
Nicholas Sherlock<br>
<br>
______________________________<u></u>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/<u></u>mailman/listinfo/nginx</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><a href="http://thewarezscene.org" target="_blank">Warez Scene</a> <a href="http://www.nexusddl.com" target="_blank">Free Rapidshare Downloads</a><br><br>