简体   繁体   English

Django缓存错误请求(400)

[英]Django cache Bad Request (400)

I currently have my seetings file configures to use the memcache cache. 我目前有我的seetings文件配置为使用内存缓存。

'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. 当前已实现为可用于所有页面。

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. 能够报告另一个错误,该错误引用了63894作为正确的端口号。 Interesting to note that it was not the port the actual site was running off - 88 . 有趣的是,这不是实际站点在运行的端口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. 也许这与它使用django manage.py runserver命令运行并且仅是开发服务器等有关。

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',
        }
    }

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 . 另请检查memcached,请检查此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM