In order to refresh pages without restarting apache, hosting the web application inside the a Mod_wsgi daemon process and restarting the process once the code is changed.
I’m quoting the official documentation from official Mod_wsgi site to here:
…if you are using Django in daemon mode and needed to change your ‘settings.py’ file, once you have made the required change, also touch the script file containing the WSGI application entry point. Having done that, on the next request the process will be restarted and your Django application reloaded.
If you are not sure whether you are using embedded mode or daemon mode, then substitute your WSGI application entry point with:
def application(environ, start_response): status = '200 OK' if not environ['mod_wsgi.process_group']: output = 'EMBEDDED MODE' else: output = 'DAEMON MODE' response_headers = [('Content-Type', 'text/plain'),('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]
If your WSGI application is running in embedded mode, this will output to the browser ‘EMBEDDED MODE’. If your WSGI application is running in daemon mode, this will output to the browser ‘DAEMON MODE’.
In order to use daemon mode, a “WSGIDaemonProcess” attribute must be specified in apache’s configuration referring to my previous post.