#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)
Change History (15)
by , 15 years ago
| Attachment: | allow-cache-control-private-override.diff added |
|---|
comment:1 by , 15 years ago
| Component: | Cache system → HTTP handling |
|---|---|
| Needs documentation: | set |
| Needs tests: | set |
| Patch needs improvement: | set |
| Triage Stage: | Unreviewed → Accepted |
Seems reasonable. However, to be accepted, this needs documentation and tests.
comment:2 by , 15 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
by , 15 years ago
| Attachment: | allow-cache-control-private-override-2.diff added |
|---|
Patch including tests and further documentation
comment:3 by , 15 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 , 15 years ago
| Needs documentation: | unset |
|---|---|
| Needs tests: | unset |
| Patch needs improvement: | unset |
comment:5 by , 15 years ago
| Severity: | → Normal |
|---|---|
| Type: | → Bug |
comment:6 by , 15 years ago
| Easy pickings: | unset |
|---|---|
| Patch needs improvement: | set |
allow-cache-control-private-override-2.diff fails to apply cleanly on to trunk
by , 15 years ago
| Attachment: | allow-cache-control-private-override-3.diff added |
|---|
New patch to integrate into recent trunk
comment:7 by , 15 years ago
| Patch needs improvement: | unset |
|---|
The new patch should work with trunk now.
comment:8 by , 15 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
by , 14 years ago
| Attachment: | allow-cache-control-private-override-4.diff added |
|---|
Update for recent trunk
comment:9 by , 14 years ago
| UI/UX: | unset |
|---|
What's the state of this bug - any objections? Uploaded another patch that merges with trunk without problems.
Simple patch