Support » Plugin: WP-FFPC » memcache cache key length

  • Resolved postme

    (@postme)


    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?

    https://wordpress.org/plugins/wp-ffpc/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author petermolnar

    (@cadeyrn)

    Let me check if I can do this with nginx as well, not only PHP; in that case, it can go default, otherwise I’ll add it as option.

    sorry for the late reply, you probably have found the following by now yourself:
    http://wiki.nginx.org/HttpSetMiscModule#set_sha1
    http://wiki.nginx.org/HttpSetMiscModule#set_md5

    I’m using this from nginx without issues.

    Plugin Author petermolnar

    (@cadeyrn)

    I’ve deployed the changes; currently testing them; it will be included in the next release, because so far it’s all fine.

    Thank you very much for the links!

    Just refused and uninstalled WP-FFPC plugin from my sites after v.1.8.1 was released due to necessity to use Nginx ngx_set_misc module. Usually on my servers I use Apache as backend and Nginx as frontend. Additionally Nginx grabs data from memcached directly. Since latest WP-FFPC was released user has been forced to use module ngx_set_misc which isn’t a part of Nginx stable release distributed as pre-build packages for Linux systems. It’s not acceptable for me to use at production infrastructure any kind of releases besides this Nginx pre-build packages from stable repository. As well as it is not convenient to build Nginx from source (as important security updates become real head ache).

    Moreover new SHA1 decoding/encoding feature consumes more server CPU resources. Please, remove sha1 URLs encoding from WP-FFPC or provide to user a possibility to select between clear text and encoded URLs.

    Plugin Author petermolnar

    (@cadeyrn)

    May I ask which package on which distribution are we talking about? Debian has at least 4 nginx packages.

    I can make it an option, that is true.

    Plugin Author petermolnar

    (@cadeyrn)

    There, in 1.8.2, sha1 is off by default; on by option.

    Wonderful, tnx Peter!

    Dear Peter, thank you very much for your smart respond and good job – it’s really well done. I don’t know if Debian Nginx flavours include ngx_set_misc module, but I know definitely that every of Ubuntu nginx flavours (nginx-core, nginx-extras, nginx-full, nginx-light and nginx-naxsi) is compiled without this module. Read this kindly: http://askubuntu.com/questions/553937/what-is-the-difference-between-the-core-full-extras-and-light-packages-for-ngi

    In my message I talked Nginx native ‘stable’ (not ‘mainline’) release repository about, which is my favorite one due to its real stability: http://nginx.org/packages/

    Thank you very much once again!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘memcache cache key length’ is closed to new replies.