How to stop my views from cacheing

20 views
Skip to first unread message

Dwayne Ghant

unread,
Dec 17, 2012, 8:14:56 PM12/17/12
to django...@googlegroups.com
Hello All: 

I have a python view that I'm building but the for some strange reason the view keeps caching.  Just to give an example: 

@api_view(['POST'])
@parser_classes((XMLParser,))
@cache_page(0)
@cache_control(private=True)
def test_view(request, format=None):
    return Response({'received data TESTING2': 'testing'})

Doesn't return "received data TESTING2': testing ." Instead, it keep returning the old cached information. Can some please tell me how to explicitly turn off caching while I'm still developing?  It a pain!! I I have listed the references below that I used to trouble shoot: 



Any help would be deeply appreciated. 

Thanx

Chris Cogdon

unread,
Dec 17, 2012, 10:02:28 PM12/17/12
to django...@googlegroups.com
You'll need to clear the cache. Remember, once the view is cached, django wont go down to the view until the cache thinks the content has expired.

Dwayne Ghant

unread,
Dec 17, 2012, 10:26:45 PM12/17/12
to django...@googlegroups.com
Thanks Chris,

That's exactly what I thought I was doing. Can you please tell me what missed? How, exactly do unclear the cache; if that's not what I'm currently doing?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ImrvggfbaEkJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Chris Cogdon

unread,
Dec 18, 2012, 12:27:18 AM12/18/12
to django...@googlegroups.com
What you're doing is saying "any _new_ results returned from this view are uncacheable", but that doesn't impact the results that are in the cache already.

Read up on this section to see how to "invalidate" the existing cache:


Thanks Chris,

To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages