memcache cache key length
-
I ran into an issue with memcache which is related to wp-ffpc so I’d thought to share it here in case it helps somebody else or might lead to a change in wp-ffpc configugration.
The issue I had was caused by using the woocommerce social login plugin. When invoking the facebook OAuth login it would come back with very lengthy urls like:
GET /wc-api/auth/facebook /int_callback?code=AQBXp9fIJ0bhu92R0IeP140baqfctKfO-Et9DnHuwBR-LK_AIejtGsc980ZiQ -y1IZZFlcxKeDqQjxc9VrLDQDDccEyEhenf-hBrW69mti588nYDGWz-yYJjnnsG9gWgOVMwfV8Gybe3z uEd4_POFKxpAZUxBGEi8KGkF6oUrr4FYVABoyh7DtpGN-MGO04xK0a481zgwxS7A_N3J-piFgY06rLLm 42xeixrfzO_VSS4M5VBR01jk5biFIgKhcfNNhXCKnaO2VqgE8DBGBi2-2_RG3GmOcJuX0DJly5uNFSwH rgnYR90x2qsuKGPl36aIco HTTP/1.1
Which choked memcache with this error:
1283 memcached sent invalid response: "CLIENT_ERROR bad command line format"
This is caused by wp-ffpc using the following key methodology:
set $memcached_key data-$scheme://$host$request_uri;
So the request url is used as a key and the returned url exceeds the constraints for memcache keys of 250 bytes.
The solution is to use a hashing algorithm to make a unique key based on the original wp-ffpc scheme which looks like:
set_sha1 $memcached_key data-$scheme://$host$request_uri;
This makes sure that the generated key still follows the original naming convention data-$scheme://$host$request_uri but at the same time doesn’t exceed the key length constraint of memcache.
Hope this helps anyone who runs into the same issue. It might be worthwhile to add to the wp-ffpc nginx config generator?
- The topic ‘memcache cache key length’ is closed to new replies.