r4fek / django-cassandra-engine

Django Cassandra Engine - the Cassandra backend for Django
BSD 2-Clause "Simplified" License
366 stars 84 forks source link

Stale Cached Response on GET #145

Closed shakram02 closed 3 years ago

shakram02 commented 3 years ago

When I POST a model to a ModelViewSet and then retrieve all objects via a GET afterwards I get a stale cached response without the new POSTed object. Does django-cassandra-engine perform any caching? If I restart the server however it brings the latest data correctly.

I checked Cassandra logs and I found no queries are made when the cached response is returned. I'm actually not sure whether this is because django-cassandra-engine or the driver or DRF. Any pointers would be helpful.

I'm already using never_cache in the ModelViewSet

class SensorReadingViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows sensor readings to be viewed or edited.
    """
    queryset = SensorReading.objects.all()
    serializer_class = SensorReadingSerializer

    @method_decorator(never_cache)
    def list(self, request, *args, **kwargs):
        return super().list(request, *args, **kwargs)
r4fek commented 3 years ago

Have you tried using get_queryset method instead of queryset variable?

r4fek commented 3 years ago

I couldn't reproduce it, so closing.