Welcome! Log In Create A New Profile

Advanced

[nginx] Is proxy_cache_valid required?

Robert Paprocki
July 25, 2014 12:32PM
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?

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

[nginx] Is proxy_cache_valid required?

Robert Paprocki July 25, 2014 12:32PM

Re: [nginx] Is proxy_cache_valid required?

BrĂ¡ulio Bhavamitra July 25, 2014 12:38PM

Re: [nginx] Is proxy_cache_valid required?

Maxim Dounin July 25, 2014 12:50PM

Re: [nginx] Is proxy_cache_valid required?

Robert Paprocki July 25, 2014 01:02PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 301
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready