best place to clear cache when restarting django server

后端 未结 5 1761
野的像风
野的像风 2020-12-13 00:45

I want memcached to be flushed on every restart/reload of django server. I use cherrypy for production and builtin server for development.

I would add this to settin

5条回答
  •  一生所求
    2020-12-13 01:36

    You typically only wan't to invalidate your caches if the code changes in a way that requires a new cache. Not on every restart.

    This is best handled by using the Django feature: settings.CACHES.VERSION, and increase that number every time you change the code that changes the format of cached data. That way, on a deploy, you automatically will use a fresh cache when you deploy new code, but keep the cache if you're code is cache-compatible with the previous code.

提交回复
热议问题