I am using nginx 1.8.1 with microcache to cache some php requests on /dev/shm
and it's working fine, however, when I reboot the server the cached files are gone (obviously) but nginx still references those in the shared memory (shouldn't it be gone on reboot?).
So what happens is that if I request one page that was cached before, it shows a error 500 and gives me an empty reply.
The same happens if I let nginx cache some pages and then manually delete the physical cached files.
I have to reload nginx in order for it to work again.
I thought that if nginx doesn't find the cache file, it would create a new one. Is this suppose to happen? Do I have to always reload nginx after deleting the cache files manually?
Is there a way for nginx to automatically recreate the file, if it doesn't find the cached file?
Relevant code:
fastcgi_cache_path /dev/shm levels=1:2 use_temp_path=off keys_zone=mcache:16m inactive=600s max_size=512m;
And also:
fastcgi_keep_conn on;
fastcgi_connect_timeout 20s;
fastcgi_send_timeout 30s;
fastcgi_read_timeout 30s;
fastcgi_cache_lock on;
fastcgi_cache_use_stale timeout updating;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache mcache;
fastcgi_cache_valid 200 301 302 5s;
fastcgi_cache_valid 403 404 5m;
add_header X-Proxy-Cache $upstream_cache_status;
I have:
sendfile off;
But still I need to reload (restart doesn't fix) nginx to regenerate cache. I'm testing this on a vultr 2Gb vm.