[Django] #32774: cache_page decorator doesn't work for cross-browser

12 views
Skip to first unread message

Django

unread,
May 22, 2021, 2:27:15 PM5/22/21
to django-...@googlegroups.com
#32774: cache_page decorator doesn't work for cross-browser
-----------------------------------------------+--------------------------
Reporter: ngohoangyell | Owner: nobody
Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 3.2
Severity: Normal | Keywords: cache
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------------+--------------------------
**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**

--
Ticket URL: <https://code.djangoproject.com/ticket/32774>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 22, 2021, 2:37:06 PM5/22/21
to django-...@googlegroups.com
#32774: cache_page decorator doesn't work for cross-browser
-------------------------------------+-------------------------------------

Reporter: ngohoangyell | Owner: nobody
Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 3.2
Severity: Normal | Resolution:

Keywords: cache | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by ngohoangyell:

Old description:

> **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**

New description:

**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**


**PR:**
https://github.com/django/django/pull/14432

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32774#comment:1>

Django

unread,
May 22, 2021, 2:38:01 PM5/22/21
to django-...@googlegroups.com
#32774: cache_page decorator doesn't work for cross-browser
-------------------------------------+-------------------------------------

Reporter: ngohoangyell | Owner: nobody
Type: Bug | Status: assigned
Component: Core (Cache system) | Version: 3.2
Severity: Normal | Resolution:

Keywords: cache | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by ngohoangyell:

Old description:

> **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**
>

> **PR:**
> https://github.com/django/django/pull/14432

New description:

**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**

--

--
Ticket URL: <https://code.djangoproject.com/ticket/32774#comment:2>

Django

unread,
May 24, 2021, 4:42:05 AM5/24/21
to django-...@googlegroups.com
#32774: cache_page decorator doesn't work for cross-browser
-------------------------------------+-------------------------------------
Reporter: HoangYell | Owner: nobody
Type: Bug | Status: closed

Component: Core (Cache system) | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: cache | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: assigned => closed
* resolution: => needsinfo


Comment:

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 `ACCEPT` header unless you explicitly add it to the
`VARY`. In such case it works as expected. Can you provide more details
and a sample project?

--
Ticket URL: <https://code.djangoproject.com/ticket/32774#comment:3>

Django

unread,
May 24, 2021, 12:44:47 PM5/24/21
to django-...@googlegroups.com
#32774: cache_page decorator doesn't work for cross-browser
-------------------------------------+-------------------------------------
Reporter: HoangYell | Owner: nobody
Type: Bug | Status: closed

Component: Core (Cache system) | Version: 3.2
Severity: Normal | Resolution: needsinfo

Keywords: cache | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by HoangYell):

Replying to [comment:3 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 `ACCEPT` header unless you explicitly add it to the
`VARY`. 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)")
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/32774#comment:4>

Reply all
Reply to author
Forward
0 new messages