Performance: File download responses
MEDIUM IMPACT
This affects page load speed and user experience by controlling how files are sent from the server to the browser for download.
from flask import Flask, send_file app = Flask(__name__) @app.route('/download') def download(): return send_file('largefile.zip', conditional=True, as_attachment=True)
from flask import Flask, send_file app = Flask(__name__) @app.route('/download') def download(): return send_file('largefile.zip')
| Pattern | Memory Usage | Response Start Time | Network Load | Verdict |
|---|---|---|---|---|
| Loading entire file in memory | High (loads full file) | Delayed (waits for full load) | High (single large transfer) | [X] Bad |
| Streaming file with conditional=True | Low (streams chunks) | Fast (starts immediately) | Optimized (chunked transfer) | [OK] Good |