Question

I've got a Flask application and in front of that an nginx-server who is configured to proxy some requests to Flask.

My question is - does it matter with regards to performance whether nginx serves static files or Flask (behind the proxy from nginx)? If so, what causes the difference?

When nginx proxies to Flask - does nginx actually add any benefit with regards to caching or similar things or does it really only forward requests?

Thank you and best regards

Was it helpful?

Solution

Yes, it counts.

nginx is written in C and handles all what shall web server handle for your static files.

Apart from speed, you will also get lower load on your Python code.

Regarding caching - if you like, nginx can serve for your app also as a cache, see NGINX doc. But if the request is to be processed by Flask, there is nothing nginx would speed up apart of offloading your app by e.g. serving static files.

The extra effort for configuring nginx for static files might not be necessary while developing an app, but for production use I would recommend it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top