1
votes

My server side is nginx-1.2.4 + php-5.3.17. I have a php script to fetch another site's content via curl, which gzip isn't enabled. While nginx has gzip on. So the data flow looks like:

                  plain/html                plain/html             gzipped
xxx site's html ==============> php(curl) ==============> nginx ============> user's browser

But now, I want to enable gzip of php' curl for the sake of speedup a little bit. Then, the procedure:

                  gzipped                plain/html             gzipped
xxx site's html ===========> php(curl) ==============> nginx ============> user's browser

Because php's curl will automatically uncompress gzipped html to plain html, so when the html is passed to nginx, nginx will do the compression again.

What I am thinking is, can php keeps gzipped data and forward it to nginx, and no need for nginx to compress one more time. The expected procedure looks like:

                  gzipped                gzipped            gzipped
xxx site's html ===========> php(curl) ===========> nginx ===========> user's browser

Best regards.

1
Why do you use php curl for that instead of simple nginx proxy_pass?VBart
@VBart Hi, what I'm gonna really do is not that simple, I need to deal with the data retrieved for further use.vvoody
proxy_store can store the data for further use.VBart

1 Answers

1
votes

You must send the Accept-Encoding header with a curl request:

curl_setopt($cURL, CURLOPT_HTTPHEADER, array("Accept-Encoding: gzip"));

and do not set the CURLOPT_ENCODING option.

Also, you may be interested in nginx gunzip module.