Search code examples
djangoapachecachingwsgi

replay in django + apache + mod_wsgi?


I have a simple django page that has a counter on it. I use Apache2 with mod_wsgi to serve it.

First, when I enter this page, the counter shows 0, as it should. The second time when I enter the page the counter shows 1 - again, it is the right behavior. The problem begins now, cause when I enter this page the third time, I get 0 again.

When I refresh it goes between 0, and 1, clearly using some cache or so. If I wait for some time and then try again, it will show 2, and 3, but will be stuck with those values, till this cache or whatever it is will be flushed, and then the counter continues.

Does somebody knows how I can get it work right (the real scenario deals with getting data from the DB, but the problems with this strange cache are the same).

BTW, I don't have any caching engine set in my django settings.


Solution

  • You are running multiple instances of your Django. Apache connects randomly to one of them.

    For testing purposes, try this in your apache.conf:

    WSGIDaemonProcess mysite processes=1 maximum-requests=500 threads=1
    

    (You may want more processes in production use.)

    See full documentation of options.