#32774 closed Bug (needsinfo)
cache_page decorator doesn't work for cross-browser
| Reported by: | HoangYell | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Cache system) | Version: | 3.2 |
| Severity: | Normal | Keywords: | cache |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
What is the issue?
- With the same URL, I made 2 requests (1 Postman, 1Firefox), but the second request was not cached
The root cause:
- First load using Postman:
- default header: Accept: */*
- Second load using Firefox:
- default header: Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
=> First load's cache_key != Second load's cache_key
Change History (4)
comment:1 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 4 years ago
| Description: | modified (diff) |
|---|
follow-up: 4 comment:3 by , 4 years ago
| Resolution: | → needsinfo |
|---|---|
| Status: | assigned → closed |
comment:4 by , 4 years ago
Replying to Mariusz Felisiak:
Thanks for this ticket, however I don't think you've explained the issue in enough detail to confirm a bug in Django. As far as I'm aware cache keys don't vary on the
ACCEPTheader unless you explicitly add it to theVARY. In such case it works as expected. Can you provide more details and a sample project?
Thank you, Seem like I don't understand enough about VARY :)
For those who are facing the same problem as me. here is an easy solution:
In settings.py
import django.utils.cache django.utils.cache.cc_delim_re = re.compile(r"(?:\s*,\s*)|(?:Accept)")
Thanks for this ticket, however I don't think you've explained the issue in enough detail to confirm a bug in Django. As far as I'm aware cache keys don't vary on the
ACCEPTheader unless you explicitly add it to theVARY. In such case it works as expected. Can you provide more details and a sample project?