[nginx] Is proxy_cache_valid required?
Robert Paprocki
rpaprocki at fearnothingproductions.net
Fri Jul 25 16:30:04 UTC 2014
Hello!
I had trouble this morning setting up a basic cache with a proxy. Based
on the proxy documentation and
http://nginx.com/resources/admin-guide/caching/, I did not expect to
have to set proxy_cache_valid; however, when this directive was not set
anywhere, I saw no cache files written.
My config file is as below:
worker_processes 1;
user freewaf freewaf;
error_log logs/error.log debug;
worker_rlimit_core 500M;
working_directory /tmp;
events {
worker_connections 1024;
}
http {
lua_package_path '/usr/local/openresty/lualib/fw/?.lua;;';
lua_shared_dict fw_shm 50m;
lua_regex_match_limit 100000000;
client_body_buffer_size 512k;
client_max_body_size 2m;
proxy_http_version 1.1;
proxy_cache_path /fw/shm/cache levels=1:2 keys_zone=fw:32m;
include conf.d/*.conf;
}
upstream upstream_2 {
server 23.226.226.175 ;
}
server {
server_name cryptobells.com www.cryptobells.com;
access_log logs/cryptobells.com.access.log;
error_log logs/cryptobells.com.error.log;
client_max_body_size 2m;
listen 80;
proxy_cache fw;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
location / {
default_type text/html;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://upstream_2;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 1d;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://upstream_2;
}
}
However, with the following commented out:
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
No caching content was written. Debug logs don't show anything out of
the ordinary (though I will post if you like); any thoughts on this?
More information about the nginx
mailing list