Opened 14 years ago

Closed 13 years ago

Last modified 13 years ago

#15499 closed Bug (fixed)

patch_cache_control should replace public/private setting if already set

Reported by: Andreas Sommer Owned by: Andreas Sommer
Component: HTTP handling Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In the following scenario

@_cache_control_iff_user_is_anonymous(public = True, must_revalidate = False, max_age = 60)
@cache_control(private = True, must_revalidate = True, max_age = 1200)
@vary_on_cookie
def myView(request):
    ...

I am applying the private caching attribute by default, and want to replace "private" with "public" iff the user is not logged in (for more aggressive caching).

But what I get with the above code is "Cache-Control: public, private, must-revalidate=False, max-age=60". So instead of just adding the "public" attribute, one should as well remove the "private" attribute.

See attached diff for a simple solution.

Attachments (4)

allow-cache-control-private-override.diff (661 bytes ) - added by Andreas Sommer 14 years ago.
Simple patch
allow-cache-control-private-override-2.diff (4.6 KB ) - added by Andreas Sommer 14 years ago.
Patch including tests and further documentation
allow-cache-control-private-override-3.diff (4.6 KB ) - added by Andreas Sommer 14 years ago.
New patch to integrate into recent trunk
allow-cache-control-private-override-4.diff (4.6 KB ) - added by Andreas Sommer 13 years ago.
Update for recent trunk

Download all attachments as: .zip

Change History (15)

by Andreas Sommer, 14 years ago

Simple patch

comment:1 by Russell Keith-Magee, 14 years ago

Component: Cache systemHTTP handling
Needs documentation: set
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

Seems reasonable. However, to be accepted, this needs documentation and tests.

comment:2 by Andreas Sommer, 14 years ago

Owner: changed from nobody to Andreas Sommer
Status: newassigned

by Andreas Sommer, 14 years ago

Patch including tests and further documentation

comment:3 by Andreas Sommer, 14 years ago

I attached a new patch with tests and documentation, please check if it's okay. It seems like the test suite doesn't have any test for patch_cache_control yet, so I created a new one.

comment:4 by Andreas Sommer, 14 years ago

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:5 by Łukasz Rekucki, 14 years ago

Severity: Normal
Type: Bug

comment:6 by patchhammer, 14 years ago

Easy pickings: unset
Patch needs improvement: set

allow-cache-control-private-override-2.diff fails to apply cleanly on to trunk

by Andreas Sommer, 14 years ago

New patch to integrate into recent trunk

comment:7 by Andreas Sommer, 14 years ago

Patch needs improvement: unset

The new patch should work with trunk now.

comment:8 by dmclain, 14 years ago

Triage Stage: AcceptedReady for checkin

by Andreas Sommer, 13 years ago

Update for recent trunk

comment:9 by Andreas Sommer, 13 years ago

UI/UX: unset

What's the state of this bug - any objections? Uploaded another patch that merges with trunk without problems.

comment:10 by Russell Keith-Magee, 13 years ago

Resolution: fixed
Status: assignedclosed

In [16657]:

Fixed #15499 -- Ensure that cache control headers don't try to set public and private as a result of multiple calls to patch_cache_control with different arguments. Thanks to AndiDog for the report and patch.

comment:11 by Russell Keith-Magee, 13 years ago

In [16673]:

[1.3.X] Fixed #15499 -- Ensure that cache control headers don't try to set public and private as a result of multiple calls to patch_cache_control with different arguments. Thanks to AndiDog for the report and patch.

Backport of r16657 from trunk.

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