django-nginx-memcache icon indicating copy to clipboard operation
django-nginx-memcache copied to clipboard

Non-Ascii Cache Key

Open minrivertea opened this issue 11 years ago • 1 comments

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?

minrivertea avatar Nov 02 '13 07:11 minrivertea

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

stevejalim avatar Nov 02 '13 19:11 stevejalim