def cache_control(max_age=None, private=False, public=False, s_maxage=None,
        must_revalidate=False, proxy_revalidate=False, no_cache=False,
        no_store=False):
    if all([private, public]):
        raise ValueError("'private' and 'public' are mutually exclusive")
    if isinstance(max_age, timedelta):
        max_age = int(total_seconds(max_age))
    if isinstance(s_maxage, timedelta):
        s_maxage = int(total_seconds(s_maxage))
    directives = []
    if public: directives.append('public')
    if private: directives.append('private')
    if max_age is not None: directives.append('max-age=%d' % max_age)
    if s_maxage is not None: directives.append('s-maxage=%d' % s_maxage)
    if no_cache: directives.append('no-cache')
    if no_store: directives.append('no-store')
    if must_revalidate: directives.append('must-revalidate')
    if proxy_revalidate: directives.append('proxy-revalidate')
    return ', '.join(directives)