#33338: Formalize @never_cache setting of Expires header
-----------------------------------------------+------------------------
               Reporter:  Andy Chosak          |          Owner:  nobody
                   Type:  Uncategorized        |         Status:  new
              Component:  Core (Cache system)  |        Version:  3.2
               Severity:  Normal               |       Keywords:  cache
           Triage Stage:  Unreviewed           |      Has patch:  0
    Needs documentation:  0                    |    Needs tests:  0
Patch needs improvement:  0                    |  Easy pickings:  0
                  UI/UX:  0                    |
-----------------------------------------------+------------------------
 The
 
[https://docs.djangoproject.com/en/dev/topics/http/decorators/#django.views.decorators.cache.never_cache
 documentation] for the `@never_cache` decorator says that it sets the
 Cache-Control header but neglects to mention that
 
[https://github.com/django/django/blob/97e9a84d2746f76a635455c13bd512ea408755ac/django/utils/cache.py#L272-L277
 it also sets] Expires to the current time (if not already set).

 Looking at
 
[https://github.com/django/django/blame/97e9a84d2746f76a635455c13bd512ea408755ac/django/utils/cache.py#L276
 the git blame], the use of Expires for `@never_cache` seems to predate the
 more modern Cache-Control. Is Expires still needed/desired as part of
 `@never_cache`?

 It also feels a little bit unexpected that if `@never_cache` is going to
 set Expires as part of its behavior that it would leave alone a pre-
 existing Expires header that was set to some far future value.

 It would be good to add tests for this behavior to
 
[https://github.com/django/django/blob/8806e8809e023017e6958b9fa0bbd960938e0a91/tests/decorators/tests.py#L496
 the existing tests], both that Expires gets set if not already set and
 that, if already set, it doesn't get modified, if that is the desired
 behavior.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33338>
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 on the web visit 
https://groups.google.com/d/msgid/django-updates/049.78fb19c3cd88b7711f5ffc96e1e1379a%40djangoproject.com.

Reply via email to