I am trying to cache some of my DRF api calls in a CDN. I need the following Cache-Control headers: public, max-age = XXXX
It's pretty simple when you use the traditional django template, you just add the @cache_page () @cache_control (public = True) decorators, but for DRF I can not find anything like it. There are quite a lot of mem caches, but I really would like the CDN to completely transfer the load from my server, I would like to cache the resulting request.
I also use modelViewSets if that matters for everything:
class EventViewSet(viewsets.ModelViewSet):
serializer_class = EventViewSet
permission_classes = (permissions.IsAuthenticatedOrReadOnly,)
pagination_class = pagination.LimitOffsetPagination
filter_backends = (filters.DjangoFilterBackend, filters.SearchFilter,)
filter_class = EventFilter
search_fields = ('name','city','state')
def get_queryset(self):
source
share