Disable caching of apache python files

I work with django and do facebook integration, which is why I need a test server. I had a lot of problems with Apache and caching .pyc files, even overflow.site/questions/99572 / ....

This solution works, but I want to know if there is an option to disable Apache caching for such files. Rebooting the server can be a problem for me.

EDIT:

Here is the django.wsgi code:

path = '/not/actual/path' if path not in sys.path: sys.path.append(path) os.environ['DJANGO_SETTINGS_MODULE'] = 'notactualproj.settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() 
+3
python django caching apache
Oct 01 '12 at 10:57
source share
1 answer

How to solve your bytecode problem

You should probably find out why these unwanted .pyc files are in the first place (are they in your repository? Should they be ignored).

As mentioned in the comments, if you have tattered .pyc files that cause problems, you can enable the deletion of all .pyc files as part of the pull process when deploying newer code to the server. Running the application will lead to the re-creation of those that are necessary when importing the modules.




Now, if you really do not want to generate bytecode, you can use the PYTHONDONTWRITEBYTECODE environment PYTHONDONTWRITEBYTECODE , but I would not want t recommend it, as this seems like a pretty overkill solution.

How to solve Apache, apparently pulling out old versions of code.

Now you need to make the difference between the two problems when playing here.

  • Older Bytecode files generated by a python file (e.g. .pyc ), which can cause a problem in certain cases, such as replacing a file with a module, but it is often a concern.
  • The WSGI mod does not reload the new code that is loading. It depends on the mode in which you start Mod WSGi, and the usual symptom is that hitting the page seems to randomly pull out a new or older version of the code.

To solve the first problem , you just need to delete the unused bytecode files. But, again, this is probably not the cause of your problem.

To solve the second problem , you have two solutions

  • Restarting apache when loading new code. Using apache2ctl -k graceful , this will be transparent to your users, and I don’t understand why “server rebooting can be a problem” if you are not using shared hosting.
  • Using code reloading, you can see the mod_wsgi documentation .

I don’t think that bytecode is your problem, and probably reloading the code.

+7
01 Oct '12 at 11:02
source share
— -



All Articles