﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
26566	Wrong example of Cache-Control in the docs	Vasiliy Faronov	Vasiliy Faronov	"Django’s [https://docs.djangoproject.com/en/dev/topics/cache/ caching docs] provide the following example of setting the Cache-Control header:

    In this example, `cache_control` tells caches to revalidate the cache on every access and to store cached versions for, at most, 3,600 seconds:

{{{
from django.views.decorators.cache import cache_control
    
@cache_control(must_revalidate=True, max_age=3600)
def my_view(request):
    # ...
}}}

This is wrong. What it really tells caches is:

* [https://tools.ietf.org/html/rfc7234#section-5.2.2.8 max-age]=3600: the response is “fresh,” and can be served directly from cache (without revalidation), for 3600 seconds;
* [https://tools.ietf.org/html/rfc7234#section-5.2.2.1 must-revalidate]: after these 3600 seconds, when the response becomes “stale,” it cannot be served from cache (without revalidation) even if otherwise that would be allowed, such as when the cache is disconnected from the network.

In my tests, with these directives, both Chrome and Firefox serve the page from cache after the first access.

The right directive for “revalidate on every access” is [https://tools.ietf.org/html/rfc7234#section-5.2.2.2 no-cache]. And as far as I know, there is no directive to limit the time for which a response is stored; only the [https://tools.ietf.org/html/rfc7234#section-5.2.2.3 no-store] directive that forbids storage entirely."	Bug	closed	Documentation	dev	Normal	fixed			Accepted	0	0	0	0	0	0
