Performance: Response headers
MEDIUM IMPACT
Response headers affect how quickly the browser can start rendering and how it caches or processes the content.
from flask import Flask, Response app = Flask(__name__) @app.route('/') def index(): headers = {'Cache-Control': 'public, max-age=3600'} return Response('Hello World', headers=headers)
from flask import Flask, Response app = Flask(__name__) @app.route('/') def index(): headers = {'X-Powered-By': 'Flask', 'Server': 'MyServer', 'Cache-Control': 'no-cache', 'Extra-Header': 'unnecessary'} return Response('Hello World', headers=headers)
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Sending many unnecessary headers | 0 | 0 | Low but delays initial paint | [X] Bad |
| Sending minimal, essential headers with caching | 0 | 0 | Minimal delay, faster paint | [OK] Good |