INNER CODE UNIT · Python

_parse_cache_control

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

def _parse_cache_control(header: str | None) -> dict[str, str | bool]:
    """Parse a ``Cache-Control`` header into a directive dict.

    Boolean directives (``no-cache``, ``no-store``) are stored as
    ``True``; value directives (``max-age=60``) are stored as strings.

    Args:
        header: Raw ``Cache-Control`` header value, or ``None``.

    Returns:
        A dict mapping lowercase directive names to ``True`` or their
        string values.
    """
    if not header:
        return {}
    directives: dict[str, str | bool] = {}
    for part in header.split(","):
        part = part.strip()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…