django-nginx-memcache
django-nginx-memcache copied to clipboard
Non-Ascii Cache Key
I have a URL like this that needs to be cached "/search/快递/" - i.e. Chinese characters in the URL. It causes a UnicodeEncodeError here:
https://github.com/torchbox/django-nginx-memcache/blob/master/nginx_memcache/cache.py#L80-L94
It seems hashlib.md5 can't handle the non-ascii (Chinese) characters when it tries to derive a cache key from the incoming URL. Would it be as simple as adding ".encode('utf-8')" to the request_path variable?
Hi Chris
Thanks for the report. I'm afraid I don't have time to try this now, but what you're suggesting makes sense and sounds worth pursuing.
Are you able to try it out? If you are, and it works, please do send me a patch or a pull request that fixes (specificially) this issue and I'll merge it.
Cheers