I set up 2 proxied server from 1 proxy server in NGINX. The 2 proxied servers simply return a HTML with a random number from Math.random() in Node.js.
My NGINX configuration is the following:
# ...
http {
upstream backend {
server IP_1:3000;
server IP_2:3000;
}
proxy_cache_path /data/cache keys_zone=my_cache:10m;
server {
location / {
proxy_cache my_cache;
proxy_pass http://backend;
}
}
# ...
}
When I go to DigitalOcean, I do find that a /data/cache directory was made, but it is empty. Now when I refresh the nginx server, I get a different random number every time as the /data/cache directory is empty. It's not the load-balancing method that is causing no caches to be written as I tried session-persistent load balancing methods such as ip_hash.
I tried the following:
Setting Cache-Control to max-age=21600.
What am I doing wrong?