我有平常的
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=drupal:16m; proxy_cache_key "$scheme$host$request_uri";
build立代理caching。 我应该如何configurationnginx以允许通过HTTP请求从caching中删除特定项目?
如果您正在尝试在Drupal上进行select性页面清除,那么我会build议您阅读本文,因为它有点长。
总结这里的主要步骤:
使用以下代码修改处理我们的Drupal请求的服务器位置:
location = /index.php { include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME /var/www/$host/drupal/index.php; fastcgi_hide_header X-Drupal-Cache; #optional fastcgi_hide_header Etag; #optional fastcgi_pass php; # Cache Settings set $nocache ""; if ($http_cookie ~ SESS) { #logged in users should bypass the cache set $nocache "Y"; } if ($request_uri ~ \? ) { # Purge doesn't handle query strings yet set $nocache "Y"; } fastcgi_cache mycache; fastcgi_cache_key $host$request_uri; fastcgi_cache_valid 200 301 1d; fastcgi_ignore_headers Cache-Control Expires; fastcgi_cache_bypass $nocache; fastcgi_no_cache $nocache; add_header X-nginx-Cache $upstream_cache_status; #optional expires epoch; }
创build一个监听localhost接口上的随机端口的新服务器。
"http://127.0.0.1:8888" 。 和你做完了!
文章的来源: 带有select性页面清除的nginxcaching