Opened 5 years ago

Last modified 3 years ago

#11997 new Bug

cache_control returns 200 OK response even page has not been changed.

Reported by: jtiai Owned by: nobody
Component: Core (Cache system) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Provided code:

@cache_page(60 * 60)
def myview(request)
    return HttpResponse('test')

Returns always 200 OK response and complete cached content. Modified since and modified dates and ETags in request and response headers do match.

Correct behavior:
Return value 304 Not Modified if cache conditions are met and do not fetch data from cache nor execute view.

Attachments (0)

Change History (3)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by niwi@…

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Bug

I passed something similar, using Generic Class Views.
With DEBUG=True works ok (Returns 304), but with DEBUG=False always returns 200 (And it creates a new cache entry for each request)

Database select with DEBUG=True

sqlite> select cache_key from testcache;
sqlite> delete from testcache;

Database select with DEBUG=False

sqlite> select cache_key from testcache;

Class View used for this test.

class CacheMixIn(object):
    """ Class for generic cache decorator. """
    @method_decorator(vary_on_headers('User-Agent', 'Cookie'))
    def dispatch(self, *args, **kwargs):
        return super(CacheMixIn, self).dispatch(*args, **kwargs)

class ObjectListMixIn(ListView):
    """ Class for generic settings for all object list. """
    allow_empty = True
    paginate_by = 20

class PostsView(CacheMixIn, ObjectListMixIn):
    queryset = Post.objects.exclude(public=False).order_by('-created_date')

comment:3 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

Add Comment

Modify Ticket

Change Properties
<Author field>
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'

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

Note: See TracTickets for help on using tickets.