简体   繁体   English

如何阻止Django缓存动态模板?

[英]How to stop Django from caching dynamic templates?

I am really new to Django, and I'm trying have my site display a server status as text. 我真的是Django的新手,我正在尝试让我的网站以文本形式显示服务器状态。 This text, however, is dynamic. 但是,此文本是动态的。 I do not understand why, if I go in my model and change the server status function to return 'cats', I don't see 'cats' appear in my browser for like 5 minutes. 我不明白为什么,如果我进入模型并更改服务器状态功能以返回“ cats”,则在大约5分钟的时间内浏览器中都不会出现“ cats”。

From what I have learned so far, I suspect this has to do with Django caching templates on the server side. 根据到目前为止的经验,我怀疑这与服务器端的Django缓存模板有关。 I have tried removing .pyc files, using @never_cache, and editing settings.py to use DummyCache, and clearing browser cache, all to no avail. 我试着使用@never_cache删除.pyc文件,并编辑settings.py以使用DummyCache,并清除浏览器缓存,但无济于事。

Does anyone know what's going on, or what a possible fix might be? 有谁知道发生了什么,或可能的解决办法是什么? Thanks! 谢谢!

make sure you don't have cache active in your MIDDLEWARE_CLASSES in your settings. 请确保您的MIDDLEWARE_CLASSES中的设置中没有激活缓存。 Also check the link below: https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache 还要检查以下链接: https : //docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache

更改代码后,请确保要重新启动服务器,例如apache或fastcgi。

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

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