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

Maxim Dounin mdounin at mdounin.ru
Wed Nov 23 17:41:23 UTC 2011


Hello!

On Wed, Nov 23, 2011 at 06:11:41PM +0100, Simone Fumagalli wrote:

> > 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/

With this config, the cache key for the request to 
"http://www.mysite.com/my-page//" will be 
"http://ALL_backend/my-page//".

Maxim Dounin



More information about the nginx mailing list