Performance: Custom status codes
Custom status codes affect how the server communicates response status to the browser, impacting how browsers handle rendering and caching.
from flask import Flask, Response app = Flask(__name__) @app.route('/') def index(): return Response('Custom error', status=450)
from flask import Flask, Response app = Flask(__name__) @app.route('/') def index(): return Response('Custom error', status=999)
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Non-standard status code (e.g., 999) | No direct DOM changes | No reflows triggered | May cause fallback paint | [X] Bad |
| Standard custom status code (e.g., 450) | No direct DOM changes | No reflows triggered | Normal paint behavior | [OK] Good |
from flask import Flask
app = Flask(__name__)
@app.route('/test')
def test():
return "Custom", 499from flask import Flask
app = Flask(__name__)
@app.route('/error')
def error():
return "Oops", status=499Pass the test and this pattern moves unknown