18-nginx缓存机制
缓存的分类:
服务端和客户端
服务端
proxy_cache mycache;
proxy_cache_valid any 1m;
proxy_ignore_headers Cache-Control; # 忽略服务器不缓存请求
proxy_cache_methods GET HEAD POST;
proxy_pass http://swoole_server;
worker_processes 2;
worker_cpu_affinity auto; #自动绑定cpu跟进程的关系
events {
worker_connections 100000; #设置单个worker连接数
}
error_log /redis_2004/logs/error.log;
http {
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream swo_http_up {
server 192.168.169.140:9001;
}
server {
listen 80;
server_name localhost;
root /redis_2004/18;
location /{
autoindex on;
}
}
}
worker_processes 2;
worker_cpu_affinity auto; #自动绑定cpu跟进程的关系
events {
worker_connections 100000; #设置单个worker连接数
}
error_log /redis_2004/logs/error.log;
http {
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
proxy_cache_path /redis_2004/18/cache levels=1:2 keys_zone=my_cache:10m max_size=10m;
upstream swo_http_up {
server 192.168.169.140:9001;
}
server {
listen 80;
server_name localhost;
root /redis_2004/18;
location /swoole {
proxy_cache my_cache;
proxy_cache_valid any 1m;
proxy_ignore_headers Cache-Control; # 忽略服务器不缓存请求
proxy_cache_methods GET HEAD POST;
proxy_pass http://swo_http_up;
}
location /{
autoindex on;
}
}