#30765: cache_control() "max_age" overrides cache_page() "timeout"
-------------------------------------+-------------------------------------
               Reporter:  Danny      |          Owner:  nobody
  Flack                              |
                   Type:  Bug        |         Status:  new
              Component:  Core       |        Version:  2.2
  (Cache system)                     |       Keywords:  cache_control
               Severity:  Normal     |  cache_page UpdateCacheMiddleware
           Triage Stage:             |  CacheMiddleware
  Unreviewed                         |      Has patch:  0
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 If you decorate a view with **both** `cache_control(max_age=3600)` and
 `cache_page(timeout=3600*24)`, the server side cache uses the `max_age`
 value instead of the `timeout` value.

 The comments in `UpdateCacheMiddleware.process_response()` indicate it's
 trying to set the timeout by first looking for the `max-age` header before
 reverting to the **default** cache_timeout :

 **Try to get the timeout from the "max-age" section of the "Cache-
 Control" header before reverting to using the default cache_timeout
 length.**

 However, `cache_page(timeout=3600*24)` is explicitly setting the
 `cache_timeout` so that is what should be used.

 In summary, if a user wants the client-side cache to be shorter-lived than
 the server-side cache, it is currently not possible using these two
 decorators.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.af00eaff3eabc6d1bdbec5ddd0bc2d30%40djangoproject.com.

Reply via email to