1

I' have a page called 'results.html' from which a user can submit a form. The problem is that sometimes I submit the form and the response is taken from the cache, and other times it actually calls the response method in views.py. Here's an example:

User submits 'The Imitation Game': the correct response is returned to the user and my response function in views prints

[19/Nov/2016 00:50:21] "POST /results/ HTTP/1.1" 200 2414
Response function called!!
Search term: The Imitation Game`

to the console. However, if the user searches this again (or any other search term he/she searched in the past) this is the response:

[19/Nov/2016 00:51:05] "GET /get_data?query=The%20Imitation%20Game HTTP/1.1" 200 18858

Clearly the response method was not called at all. This is also very evident on the front end because out-of-date data is returned to the user on subsequent requests.

The kicker here is that I am using a dummy cache:

# Use dummy cache for development and testing
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
    },
    'deployment': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    }
}

and DEBUG = True. I am also marking the response method as follows:

@never_cache
def results(request):

I cleared my browser cache, so it's not that either. I'm amazed that this is at all possible. Any help would be much appreciated.

  • Can you try with disabled cache in the browser? - http://stackoverflow.com/a/7000899/3930114 I think this is a browser side issue. You can also see in the network section which query is sent to your django server as additional confirmation. – Aditya Nov 19 '16 at 01:23

1 Answers1

0

It turns out I wasn't properly clearing my browser history in Chrome. When I "cleared" it I had forgotten to select "clear cached files and images". Clearing those fixed the problem (there was nothing wrong with my code).