Serializers#

Response serialization utilities. See Serializers for general usage info.

Summary:

The cattrs library includes a number of pre-configured converters that perform some pre-serialization steps required for specific serialization formats.

The module requests_cache.serializers.preconf wraps those converters as serializer Stage objects, which are then combined into a SerializerPipeline. Preconf converters run after the base converter and before the format’s dumps() (or equivalent) method. For example, for JSON:

  • Run base converter (CattrStage) to convert CachedResponse to a dict

  • Run json prconf converter to convert binary response body to base84

  • Run json.dumps()

For any optional libraries that aren’t installed, the corresponding serializer will be a placeholder class that raises an ImportError at initialization time instead of at import time.

Modules in requests_cache.serializers package: