So, yesterday I implemented cache on nginx, it semes to be working alright so far, the thing is ,my nginx error.log displays this:
2024/03/22 02:38:31 [notice] 1757084#1757084: http file cache: /data/cache/nginx 0.000M, bsize: 4096
2024/03/22 02:38:31 [notice] 1757080#1757080: signal 17 (SIGCHLD) received from 1757084
2024/03/22 02:38:31 [notice] 1757080#1757080: cache loader process 1757084 exited with code 0
2024/03/22 02:38:31 [notice] 1757080#1757080: signal 29 (SIGIO) received
Besides, the directory where the cache is supposed to store data is empty . here is my nginx.conf:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=4r/s;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
proxy_cache_path /data/cache/nginx
keys_zone=MyCache:10m
levels=1:2
inactive=60m
max_size=20g;
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
limit_req zone=mylimit burst=4 nodelay;
listen 80;
listen [::]:80;
server_name siteurl;
return 301 https://$server_name$request_uri;
}
server {
limit_req zone=mylimit burst=4 nodelay;
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name siteurl;
root /data/wordpress-cloudpanel;
client_max_body_size 4G;
keepalive_timeout 5;
index index.php index.html index.htm;
location / {
#This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
proxy_cache MyCache;
proxy_cache_valid any 30m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
try_files $uri $uri/ /index.php?$args;
add_header X-Proxy-Cache $upstream_cache_status;
#try_files $uri /index.html index.php;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi_params;
proxy_cache MyCache;
proxy_cache_valid any 30m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
fastcgi_intercept_errors on;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
add_header X-Proxy-Cache $upstream_cache_status;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
#expires max;
#log_not_found off;
}
location ~ ^/(.+)/amp$ {
rewrite ^/(.+)/amp$ /$1 permanent;
}
# Redirect comment-page-x to the original post
# rewrite ^/(.+)/comment-page-([0-9]+)/?$ /$1 permanent;
location ~ /\.git {
deny all;
return 403;
}
location = /xmlrpc.php {
deny all;
return 403;
}
#configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
}
}
When I was reading about it, I found this "The cache loader runs only once, right after NGINX starts. It loads metadata about previously cached data into the shared memory zone", which is exactly what my error.log displays, however, after the process is done nothing is loaded into the cache.
by the way, I gave Nginx user the necessary permissions and ownership of the directory where the data is supposed to be stored. what am I missing here? is the cache loader process supposed to exit?
thanks in advance!!