How can I check that the nginx gzip_static module is working?

后端 未结 6 833
遇见更好的自我
遇见更好的自我 2021-01-30 00:58

How can I check that nginx is serving the .gz version of static files, if they exist?

I compiled nginx with the gzip static module, but I don\'t see any mention of the .

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-30 01:45

    Use strace. First, you need to detect PID of nginx process:

    # ps ax | grep nginx
    25043 ?        Ss     0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
    25044 ?        S      0:02 nginx: worker process
    

    Ok, so 25044 is the worker process. Now, we trace it:

    # strace -p 25044 2>&1 | grep gz
    open("/var/www/css/ymax.css.gz", O_RDONLY|O_NONBLOCK) = 438
    open("/var/www/css/patches/patch_my_layout.css.gz", O_RDONLY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
    open("/var/www/yaml/core/iehacks.css.gz", O_RDONLY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
    open("/var/www/js/koznazna5.js.gz", O_RDONLY|O_NONBLOCK) = -1 ENOENT (No such file or directory)
    open("/var/www/css/ymax.css.gz", O_RDONLY|O_NONBLOCK) = 216
    

    As you can see, it is trying to find .gz versions of files.

提交回复
热议问题