florimondmanca / asgi-caches

Server-side HTTP caching for ASGI applications, inspired by Django's cache framework

Home Page:https://florimondmanca.github.io/asgi-caches/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for private and public Cache-Control attributes

florimondmanca opened this issue · comments

While #4 will add support for adding arbitrary Cache-Control attributes, the private and public attributes are a bit special. They are exclusive, in that only one of them should be present in the Cache-Control header. Besides, if private is present then the response should never be cached.

To implement this feature:

  • Modify the Cache-Control header generation to allow passing private=True and public=True to the @cache_control header (resulting in the private or public directives being present in the Cache-Control header).
    • Make sure that only one of private or public is passed to @cache_control, or raise an exception (e.g. ValueError).
    • If one of public or private is already present in the Cache-Control header (this may happen if e.g. the view returned as response with Cache-Control: public), it should be overridden.
  • In store_in_cache(), make sure to not store the response in the cache if the private cache-control directive is present.
  • Add tests for the new behavior (and modify the one that was testing that private and public weren't supported yet).

Note that this can only be tackled once #4 has been resolved.

#4 is in, so we can start working on this issue. :)