Nginx Cache and WP canonical URL create infinite loop (bug ?)

Simone Fumagalli simone.fumagalli at contactlab.com
Wed Nov 23 17:11:41 UTC 2011


> Could you please show your config?  

Nothing special, here we go (only important parts)

server {

	server_name www.mysite.com
	listen 1.2.3.4:80

	proxy_redirect     off;
	proxy_set_header   Host             $host;
	proxy_set_header   X-Real-IP        $remote_addr;
	proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
	proxy_store_access  user:rw  group:rw  all:r;

	location / {
	
		# If logged in, don't cache.
		if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) {
			set $do_not_cache 1;
		}
		
		# Response in not cached	
		proxy_no_cache $do_not_cache;
		
		# Response is not taken from the cache
		proxy_cache_bypass $do_not_cache;
		
		proxy_cache MY_CACHE;
		proxy_pass http://ALL_backend;

	}
	
	location ~ /purge(/.*) {
		proxy_cache_purge MY_CACHE "$scheme://$host$1$is_args$args";
	}

}

> By default nginx will use the same uri in cache as it will use in request to upstream, and this shouldn't happen

AFAIK when I require http://www.mysite.com/my-page// the key for the cache is set to http://www.mysite.com/my-page/

Ciao

--
Simone



More information about the nginx mailing list