简体   繁体   中英

Serving static files on top of mod_wsgi and dJango (server: Heroku)

I'm having trouble serving static files through my web server running mod_wsgi and dJango. Our server provider is Heroku.

Because the files are static, and should not be evaluated, I've heard that they should be served directly instead of going through mod_wsgi instead and dJango should not touch them?

I feel like this should be a simple thing, but I'm struggling with it. I'd really appreciate it if anyone could point me in the right directing as to how I should be attempting to store and serve static files?

The idea is to use the Web server to handle requests for static files and not pass those through to your Django instance. The reason for that is that Web servers, unlike your Django application, are optimized for delivering static content.

The only thing you really need to do is configure your Web server to handle requests that match the path of your STATIC_URL and MEDIA_URL by setting the document root for those requests to the location where your static and media files are stored by your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM