curl 可以看到能输出gzip 但是在浏览器下却没有输出
环境 nginx + php-fpm
curl -v -I -H "Accept-Encoding: gzip,deflate" http://www.ihezhu.com/
* About to connect() to www.ihezhu.com port 80 (#0) * Trying 210.51.54.180... connected > HEAD / HTTP/1.1 > User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3 > Host: www.ihezhu.com > Accept: */* > Accept-Encoding: gzip,deflate > <p>但直接浏览器却没有看到输出Content-Encoding 大概怎么回事?<br> 谢谢</p><p>====update<br> 原因暂时还不明, 说下我做的测试<br> 用fiddler访问, <code>不输出</code><br> 用fiddler按照curl构造参数, <code>不输出</code><br> 用chrome插件模拟curl请求, <code>不输出</code><br> 在本机模拟了服务器配置一致的环境(php.ini, fastcgi, nginx.conf以及站点配置), <code>可以输出</code><br> 现在准备在curl中模拟browser的请求, 看看怎样</p> <h2 id="回复内容">回复内容:</h2> <p>环境 nginx + php-fpm</p><p><code>curl -v -I -H "Accept-Encoding: gzip,deflate" http://www.ihezhu.com/</code></p><pre class="brush:php;toolbar:false">* About to connect() to www.ihezhu.com port 80 (#0) * Trying 210.51.54.180... connected > HEAD / HTTP/1.1 > User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3 > Host: www.ihezhu.com > Accept: */* > Accept-Encoding: gzip,deflate > <p>但直接浏览器却没有看到输出Content-Encoding 大概怎么回事?<br> 谢谢</p><p>====update<br> 原因暂时还不明, 说下我做的测试<br> 用fiddler访问, <code>不输出</code><br> 用fiddler按照curl构造参数, <code>不输出</code><br> 用chrome插件模拟curl请求, <code>不输出</code><br> 在本机模拟了服务器配置一致的环境(php.ini, fastcgi, nginx.conf以及站点配置), <code>可以输出</code><br> 现在准备在curl中模拟browser的请求, 看看怎样</p> <p class="answer fmt" data-id="1020000000162404"> </p><p>建议你用wireshark抓包看看,可能只是chrome没显示这个出来。</p><p>感觉chrome的开发者工具不那么靠谱,比如显示出了 Transfer-Encoding: chunked,但是显示出来的却找不是原始的response(不是chunked的格式)。</p> <p class="answer fmt" data-id="1020000000162529"> </p><p>这个问题很有意思, 我猜是你在curl的时候, request headers提供的不足, 所以没有被CDN cache到.</p><p>但是在浏览器的情况下, request headers很完整, 所以CDN就起作用了, 既然CDN服务器节点靠近你自己的网络, 那么就不用压缩了, 直接返回给你明文, 跳过gzip节省浏览器解压时间, 加速网页响应.</p><p>我这么猜是因为response header里面有个Vary, 查了一下Vary的功能和CDN有关</p>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

Steps to start Nginx in Linux: Check whether Nginx is installed. Use systemctl start nginx to start the Nginx service. Use systemctl enable nginx to enable automatic startup of Nginx at system startup. Use systemctl status nginx to verify that the startup is successful. Visit http://localhost in a web browser to view the default welcome page.

In Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP

Answer to the question: 304 Not Modified error indicates that the browser has cached the latest resource version of the client request. Solution: 1. Clear the browser cache; 2. Disable the browser cache; 3. Configure Nginx to allow client cache; 4. Check file permissions; 5. Check file hash; 6. Disable CDN or reverse proxy cache; 7. Restart Nginx.

The server does not have permission to access the requested resource, resulting in a nginx 403 error. Solutions include: Check file permissions. Check the .htaccess configuration. Check nginx configuration. Configure SELinux permissions. Check the firewall rules. Troubleshoot other causes such as browser problems, server failures, or other possible errors.

How to fix Nginx 403 Forbidden error? Check file or directory permissions; 2. Check .htaccess file; 3. Check Nginx configuration file; 4. Restart Nginx. Other possible causes include firewall rules, SELinux settings, or application issues.
