#37054: Precompute the Referrer-Policy header value during middleware
initialization
-------------------------------------+-------------------------------------
     Reporter:  Mason Lyons          |                    Owner:  Mason
         Type:                       |  Lyons
  Cleanup/optimization               |                   Status:  assigned
    Component:  HTTP handling        |                  Version:  6.0
     Severity:  Normal               |               Resolution:
     Keywords:  middleware           |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Natalia Bidart):

 Replying to [comment:2 Mason Lyons]:
 > PR available: https://github.com/django/django/pull/21146

 Hello, thank you for your ticket. I understand the rationale in the report
 but the proposed change needs stronger justification and careful
 consideration of compatibility. Specifically:

 1. Performance evidence: this is a micro-optimization. Moving a small
 string normalization from `process_response()` to `__init__()` may reduce
 per-request work, but the cost is negligible relative to overall request
 handling. Please provide evidence of a measurable performance improvement
 in a production-grade Django setup (e.g., benchmarks under realistic load)
 to justify the change. Also consider registering a benchmark check in
 django-asv.
 2. Backward compatibility: the change is not backward compatible and
 introduces subtle behavior differences. Among others: generators would be
 consumed at initialization instead of on first request, changes to
 `self.referrer_policy` after initialization would no longer be reflected
 in responses, subclasses overriding `process_response()` or relying on
 `self.referrer_policy` being evaluated per request would observe different
 behavior, etc.

 Given these points, I'll be closing the ticket accordingly.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37054#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019dabceabaa-f8caa918-8a82-42c7-b71d-f9d3990b9095-000000%40eu-central-1.amazonses.com.

Reply via email to