Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15499 closed Bug (fixed)

patch_cache_control should replace public/private setting if already set

Reported by: AndiDog Owned by: AndiDog
Component: HTTP handling Version: master
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 AndiDog 3 years ago.
Simple patch
allow-cache-control-private-override-2.diff (4.6 KB) - added by AndiDog 3 years ago.
Patch including tests and further documentation
allow-cache-control-private-override-3.diff (4.6 KB) - added by AndiDog 3 years ago.
New patch to integrate into recent trunk
allow-cache-control-private-override-4.diff (4.6 KB) - added by AndiDog 3 years ago.
Update for recent trunk

Download all attachments as: .zip

Change History (15)

Changed 3 years ago by AndiDog

Simple patch

comment:1 Changed 3 years ago by russellm

  • Component changed from Cache system to HTTP handling
  • Needs documentation set
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

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

comment:2 Changed 3 years ago by AndiDog

  • Owner changed from nobody to AndiDog
  • Status changed from new to assigned

Changed 3 years ago by AndiDog

Patch including tests and further documentation

comment:3 Changed 3 years ago by AndiDog

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 Changed 3 years ago by AndiDog

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:5 Changed 3 years ago by lrekucki

  • Severity set to Normal
  • Type set to Bug

comment:6 Changed 3 years ago by patchhammer

  • Easy pickings unset
  • Patch needs improvement set

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

Changed 3 years ago by AndiDog

New patch to integrate into recent trunk

comment:7 Changed 3 years ago by AndiDog

  • Patch needs improvement unset

The new patch should work with trunk now.

comment:8 Changed 3 years ago by dmclain

  • Triage Stage changed from Accepted to Ready for checkin

Changed 3 years ago by AndiDog

Update for recent trunk

comment:9 Changed 3 years ago by AndiDog

  • UI/UX unset

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

comment:10 Changed 3 years ago by russellm

  • Resolution set to fixed
  • Status changed from assigned to closed

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 Changed 3 years ago by russellm

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.