Join the community today
Become a Member

Cache-Enabler Plugin How to check if cache is served with nginx?

Discussion in 'Blogs & CMS usage' started by Chuong Luong, Oct 14, 2020.

  1. Chuong Luong

    Chuong Luong New Member

    17
    0
    1
    Aug 8, 2019
    Ratings:
    +1
    Local Time:
    7:49 PM
    Hi,

    I am using htop to track process. What I usually see is mostly php running (CPU 3-10%), while nginx rarely run (CPU 0-0.7%) even though the cache size is a few GB already. So, does cache successfully serve to visitors? I though nginx should run most of the time.

    I check the x-handler when page is load 2nd time is: wp

    Also saw the timestamp at the end of html.

    Is Centmin suppose to serve cache all through nginx? In my case, it seems php is still serve caches.

    My visitors are all guests, no logged-in usera.

    Thanks!
     
  2. eva2000

    eva2000 Administrator Staff Member

    45,441
    10,312
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,994
    Local Time:
    10:49 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x
    You can check your PHP-FPM extended status for what PHP-FPM is processing
    Code (Text):
    curl -s localhost/phpstatus
    

    and
    Code (Text):
    curl -s "localhost/phpstatus?full"
    

    or json format
    Code (Text):
    curl -s "localhost/phpstatus?full&json" | jq
    

    and Nginx logs in as per Centmin Mod Configuration Files - CentminMod.com LEMP Nginx web stack for CentOS at /home/nginx/domains/yourdomain.com/log/access.log to see what requests are made

    You can also configure Nginx logs for optional JSON format too Nginx - How To Configure Nginx For JSON Based Access Logging if you're more comfortable with JSON
     
  3. Chuong Luong

    Chuong Luong New Member

    17
    0
    1
    Aug 8, 2019
    Ratings:
    +1
    Local Time:
    7:49 PM
    With:

    Code:
    curl -s "localhost/phpstatus?full"
    Output is something like this:

    Code:
    pool:                 www
    process manager:      ondemand
    start time:           14/Oct/2020:08:38:07 +0000
    start since:          17318
    accepted conn:        67314
    listen queue:         0
    max listen queue:     75
    listen queue len:     65535
    idle processes:       0
    active processes:     5
    total processes:      5
    max active processes: 105
    max children reached: 1
    slow requests:        0
    
    ************************
    pid:                  12773
    state:                Running
    start time:           14/Oct/2020:13:26:45 +0000
    start since:          0
    requests:             1
    request duration:     481
    request method:       GET
    request URI:          /phpstatus?full
    content length:       0
    user:                 -
    script:               -
    last request cpu:     0.00
    last request memory:  0
    
    ************************
    pid:                  12692
    state:                Reading headers
    start time:           14/Oct/2020:13:25:31 +0000
    start since:          74
    requests:             47
    request duration:     8746867
    request method:       -
    request URI:          -
    content length:       0
    user:                 -
    script:               -
    last request cpu:     0.00
    last request memory:  0
    
    ************************
    pid:                  12619
    state:                Running
    start time:           14/Oct/2020:13:24:37 +0000
    start since:          128
    requests:             160
    request duration:     137334
    request method:       GET
    request URI:          /index.php
    content length:       0
    user:                 -
    script:               /home/nginx/domains/mydomain.com/public/index.php
    last request cpu:     0.00
    last request memory:  0
    
    ************************
    pid:                  12638
    state:                Reading headers
    start time:           14/Oct/2020:13:24:53 +0000
    start since:          112
    requests:             118
    request duration:     10027680
    request method:       -
    request URI:          -
    content length:       0
    user:                 -
    script:               -
    last request cpu:     0.00
    last request memory:  0
    
    ************************
    pid:                  10078
    state:                Reading headers
    start time:           14/Oct/2020:13:15:33 +0000
    start since:          672
    requests:             263
    request duration:     406107
    request method:       -
    request URI:          -
    content length:       0
    user:                 -
    script:               -
    last request cpu:     0.00
    last request memory:  0
    With:

    Code:
    cat /home/nginx/domains/mydomain.com/log/access.log
    I have lots of output, ie:

    Code:
    IP - - [14/Oct/2020:13:05:44 +0000] "GET /url.html HTTP/1.1" 200 21487 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:75.0) Gecko/20100101 Firefox/75.0"
    
    IP - - [14/Oct/2020:13:07:41 +0000] "GET /url.html HTTP/1.1" 200 22782 "-" "Scrapy/1.5.2 (+https://scrapy.org)"
    
    IP - - [14/Oct/2020:13:07:50 +0000] "GET /url.html HTTP/1.1" 200 22642 "https://url.html" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
    
    From these two, how to know if the cache is served with nginx?

    Thank you.
     
  4. eva2000

    eva2000 Administrator Staff Member

    45,441
    10,312
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,994
    Local Time:
    10:49 PM
    Nginx 1.19.x
    MariaDB 5.5/10.x