Performance: HttpRequest object
MEDIUM IMPACT
The HttpRequest object affects server-side request handling speed and how quickly the server can start processing and responding to user requests.
def view(request): user_agent = request.META.get('HTTP_USER_AGENT', '') body = request.body # Access once and reuse process(body) process(body)
def view(request): user_agent = request.META.get('HTTP_USER_AGENT', '') # Accessing request body multiple times body1 = request.body body2 = request.body # Processing without caching process(body1) process(body2)
| Pattern | Server CPU Usage | Memory Usage | Request Latency | Verdict |
|---|---|---|---|---|
| Repeated request.body access | High | High | Increased by ms | [X] Bad |
| Single request.body access with caching | Low | Moderate | Minimal increase | [OK] Good |