Opened 10 years ago

Closed 5 years ago

#23755 closed New feature (fixed)

patch_cache_control should special case "no-cache"

Reported by: thenewguy Owned by: Flavio Curella
Component: Core (Cache system) Version: dev
Severity: Normal Keywords:
Cc: wgordonw1@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

From my cursory reading of http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html, it looks like patch_cache_control needs to special case "no-cache".

no-cache
If the no-cache directive does not specify a field-name, then a cache MUST NOT use the response to satisfy a subsequent request without successful revalidation with the origin server. This allows an origin server to prevent caching even by caches that have been configured to return stale responses to client requests.
If the no-cache directive does specify one or more field-names, then a cache MAY use the response to satisfy a subsequent request, subject to any other restrictions on caching. However, the specified field-name(s) MUST NOT be sent in the response to a subsequent request without successful revalidation with the origin server. This allows an origin server to prevent the re-use of certain header fields in a response, while still allowing caching of the rest of the response.

For example, to integrate a site that uses "Vary: Cookie" with AWS CloudFront, one must use 'Cache-Control: no-cache="Set-Cookie"' if a response does not vary by cookie. (I've confirmed this with AWS support as of 10/31/2014).

patch_cache_control does not treat "no-cache" as a list. If you call patch_cache_control(response, no_cache="Set-Cookie") and then patch_cache_control(response, no_cache="foo"), you end up with 'Cache-Control: no-cache="foo"'

Also, no_cache=True should take precedence over no_cache="foo" regardless of the order it is applied.

I found Ticket https://code.djangoproject.com/ticket/13008 which proposes to add "no-cache" to @never_cache. Just wanted to link it here since they are related.

Change History (8)

comment:1 by thenewguy, 10 years ago

Cc: wgordonw1@… added

comment:2 by Tim Graham, 10 years ago

Component: UncategorizedCore (Cache system)
Description: modified (diff)
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature
Version: 1.7master

comment:3 by Flavio Curella, 5 years ago

Owner: changed from nobody to Flavio Curella
Status: newassigned

comment:4 by Flavio Curella, 5 years ago

Has patch: set

comment:5 by Mariusz Felisiak, 5 years ago

Needs documentation: set
Patch needs improvement: set

comment:6 by Flavio Curella, 5 years ago

Needs documentation: unset
Patch needs improvement: unset

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

In 9facc900:

Refs #23755 -- Added tests for patch_cache_control() with no-cache Cache-Control directive.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: assignedclosed

In ed112fad:

Fixed #23755 -- Added support for multiple field names in the no-cache Cache-Control directive to patch_cache_control().

https://tools.ietf.org/html/rfc7234#section-5.2.2.2

Note: See TracTickets for help on using tickets.
Back to Top