1

I am trying to debug my django code on the server. I am using a multi-tenant schema app so it is easier to run from the server over wsgi rather than using manage.py runserver.

The problem is every time I change some code, view.py, (and it might be more just when I have an error, or had an error) I hit refresh in Firefox and each time I hit refresh it seems to be showing me the past 3-4 page instances before showing me the current change.

Now, I have tried the following:

settings.py:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
    }
}

But that didn't appear to work so tried:

apache virtualhost conf

## Added this to stop some weird page caching happening. Appears to be working properly now.
#http://stackoverflow.com/questions/1633684/how-to-disable-django-mod-wsgi-page-caching
WSGIScriptReloading On

# http://stackoverflow.com/questions/11532636/prevent-http-file-caching-in-apache-httpd-mamp
<filesMatch "\.(html|htm|js|css)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>

As well someone suggested to try the Private Browser in firefox, but the same thing.

As well I tried incrementing a "?v=1" type of thing at the end of the URL, but still didn't help.

So, I can't tell what thing is appearing to cache the past few pages everytime I hit refresh in the browser. This is really slowing down my progress.

Any ideas would be greatly appreciated.

brechmos
  • 1,164
  • 1
  • 9
  • 19

2 Answers2

3

I came across this same issue long ago with Chrome, and it is quite frustrating. The solution that worked for me in Chrome is to open the developer tools and then under the dev tools settings, make sure to check the option Disable cache (while DevTools is open). After this any refresh of the page (while the dev tools are open) will be the current version.

Firefox has this same option in it's developer "Toolbox". It's under Advanced settings with the label Disable Cache (when toolbox is open).

Fiver
  • 8,735
  • 8
  • 41
  • 59
  • That is helpful to know but doesn't appear to be the solution. I tried it and am still getting a similar issue. I actually just tried it in Safari too and am getting something similar, so... it seems it might be a apache/wsgi or django issue. If there are other ideas I can try, I would love to hear. – brechmos Nov 01 '14 at 18:25
  • Bummer, that would have been an easy fix. Can you elaborate on what you mean by `the past 3-4 page instances before showing me the current change`? – Fiver Nov 02 '14 at 00:21
  • Sorry for the delay. I am, just now, watching my apache error.log and browser (which are consistent). I hit reload on the browser and my apache log shows me "[Tue Nov 04 12:57:26.982460 2014] [:error] [pid 20439] here [Tue Nov 04 12:57:28.046300 2014] [:error] [pid 20149] recurr". I hit reload again and it shows me "Tue Nov 04 12:57:41.686496 2014] [:error] [pid 20523] here" and I hit reload again and I get "[Tue Nov 04 12:57:48.359550 2014] [:error] [pid 10995] here [Tue Nov 04 12:57:49.212063 2014] [:error] [pid 10995] – brechmos Nov 04 '14 at 13:00
  • The first one is correct, then the second one is an older version of the view as there is no "recurr" in there. Then the third one is a much older version of the view as I was printing out the " – brechmos Nov 04 '14 at 13:03
0

Actually, I don't think this has anything to do with apache.

I had the same issue during the development of my sites because of pages kept in the cache.
As I was using memcached I used to perform a service memcached restart to empty the cache but it was not handy since I had to re log in to access some pages.
I figured another solution after some time : disable UpdateCacheMiddleware and FetchFromCacheMiddleware for development :

#setting.py
if CACHE_PAGES:
    MIDDLEWARE_CLASSES = (
        'django.middleware.cache.UpdateCacheMiddleware',
        'django.middleware.cache.FetchFromCacheMiddleware',
    )
else:
    MIDDLEWARE_CLASSES = ()

MIDDLEWARE_CLASSES += (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

Now I can make changes on my pages and they will be effective after a refresh.

PhilipGarnero
  • 1,432
  • 1
  • 15
  • 23