INNER CODE UNIT · Python

_cache_control_value

redis/fastapi-redis-sdk · src/redis_fastapi/cache.py:166

def _cache_control_value(max_age: int, private: bool) -> str:
    """Build a ``Cache-Control`` response header value.

    When *max_age* is ``0`` (no TTL), no ``max-age`` directive is emitted;
    the header contains only ``no-cache`` (always revalidate via ETag).

    Args:
        max_age: The ``max-age`` value in seconds.  ``0`` means no expiry.
        private: Whether to include the ``private`` directive.

    Returns:
        The formatted header value string.
    """
    if max_age <= 0:
        base = "no-cache"
    else:
        base = f"max-age={max_age}"
    if private:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…