Red Shift
Red Shift

Reputation: 1312

Django cache Bad Request (400)

I currently have my seetings file configures to use the memcache cache.

'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache'

Whilst the site runs flawlessly, I see debug lines such as:

[05/Dec/2014 15:28:53] code 400, message Bad HTTP/0.9 request type ('get')
[05/Dec/2014 15:28:53] "get :1:views.decorators.cache.cache_header..439e23553bea98b3b35e7b94c1f72576.en-gb.AUS_Eastern_Standard_Time" 400 -
[05/Dec/2014 15:28:53] "GET /RSA/ HTTP/1.1" 200 968

So I'm interested in learning how to fix this, and how I can actually test whether the backend cache is being used. It is currently implemented to be used with all pages.

Upvotes: 0

Views: 788

Answers (2)

Red Shift
Red Shift

Reputation: 1312

Went back to the docks and started playing around with the port number for the location.

Was able to make it report a different error that referenced 63894 as being the correct port number. Interesting to note that it was not the port the actual site was running off - 88. Maybe it was something to do with the fact that it was running with the django manage.py runserver command and was only a development server etc.

Anyway this fixed the problem. Code below as a reference.

CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
            'LOCATION': '127.0.0.1:63894',
        }
    }

Upvotes: 1

Gautam Bhalla
Gautam Bhalla

Reputation: 1210

Adapted from previous response

The only possible reason I see in bad request error is due to misconfiguration of hosts settings as also discussed here.

Also to check for memcached, Please check this link.

Upvotes: 0

Related Questions