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.
* type: Uncategorized => Cleanup/optimization
* easy: 0 => 1
* stage: Unreviewed => Accepted
Comment:
Agreed, we should clarify that the `Expires` header is added if it isn't
already set in `add_never_cache_headers()` and `@never_cache` docs (see
related `patch_response_headers()`
[https://docs.djangoproject.com/en/stable/ref/utils/#django.utils.cache.patch_response_headerst
docs]). Extra tests are also welcome (as always).
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:1>
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:2>
* owner: nobody => Marcelo Galigniana
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:3>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/15167 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:4>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:5>
Comment (by Marcelo Galigniana):
[https://github.com/django/django/pull/15176 NEW PR against 'main']
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:6>
* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:7>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"e61abab6e0d57c333289790496f358bb8ee4c565" e61abab]:
{{{
#!CommitTicketReference repository=""
revision="e61abab6e0d57c333289790496f358bb8ee4c565"
Refs #33338 -- Added never_cache() tests for Expires header.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"669dcefc04837c35fc2ec5ce906d84397005965d" 669dcefc]:
{{{
#!CommitTicketReference repository=""
revision="669dcefc04837c35fc2ec5ce906d84397005965d"
Fixed #33338 -- Doc'd that never_cache() decorator set Expires header.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:9>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"cc5bbd447bec57165d5bdf062128fdee0df81ee4" cc5bbd44]:
{{{
#!CommitTicketReference repository=""
revision="cc5bbd447bec57165d5bdf062128fdee0df81ee4"
[4.0.x] Fixed #33338 -- Doc'd that never_cache() decorator set Expires
header.
Backport of 669dcefc04837c35fc2ec5ce906d84397005965d from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33338#comment:10>