Cacheops not working in Production.
Cacheops is not working for me in production but it does in development . I can't tell if it's my settings. Here is my settings. `CACHEOPS_DEGRADE_ON_FAILURE=True CACHEOPS_ENABLED = True CACHEOPS_REDIS = { 'host': 'localhost', 'port': 6379,
} CACHEOPS_DEFAULTS = { 'timeout': 60*60 } CACHEOPS = {
'libman.*': {'ops':'all'},
}`
How do you know it is not working?
How do you know it is not working?
Through DjDT. The no of queries are the same the first time I access a page and after I refresh...
There could be many reasons:
- Fail to connect to redis, see logs, there might be warnings. Because of
CACHEOPS_DEGRADE_ON_FAILURE = Trueyou still continue. - Queries are not the same, this is common if timestamp or some random component is involved.
- Cache got invalidated.
- Queries are not being cached because of transactions. Any transaction once performed any write query starts bypassing cache to be safe.
Aside from looking into logs you may try redis-cli monitor to see whether cache is being saved and or deleted. Or you may use signals cacheops provides to log something, see README.
[Django] ERROR (EXTERNAL IP): Internal Server Error: /login/
Traceback (most recent call last):
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/core/handlers/base.py", line 204, in _get_response
response = response.render()
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/response.py", line 105, in render
self.content = self.rendered_content
File "/workspace/.heroku/python/lib/python3.9/site-packages/sentry_sdk/integrations/django/templates.py", line 73, in rendered_content
return real_rendered_content.fget(self)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/response.py", line 83, in rendered_content
return template.render(context, self._request)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/workspace/.heroku/python/lib/python3.9/site-packages/django/template/base.py", line 168, in render
with context.bind_template(self):
File "/workspace/.heroku/python/lib/python3.9/contextlib.py", line 117, in __enter__
return next(self.gen)
File "/workspace/.heroku/python/lib/python3.9/site-packages/debug_toolbar/panels/templates/panel.py", line 48, in _request_context_bind_template
updates.update(context)
Exception Type: TypeError at /login/
Exception Value: 'NoneType' object is not iterable
Request information:
USER: AnonymousUser
There could be many reasons:
- Fail to connect to redis, see logs, there might be warnings. Because of
CACHEOPS_DEGRADE_ON_FAILURE = Trueyou still continue.- Queries are not the same, this is common if timestamp or some random component is involved.
- Cache got invalidated.
- Queries are not being cached because of transactions. Any transaction once performed any write query starts bypassing cache to be safe.
Aside from looking into logs you may try
redis-cli monitorto see whether cache is being saved and or deleted. Or you may use signals cacheops provides to log something, see README.
Doesn't look related to cacheops