Module: WCC::JsonAPI::SerializerWithCaching

Extended by:
ActiveSupport::Concern
Defined in:
lib/wcc/jsonapi/concerns/serializer_with_caching.rb

Overview

This is a really complex module that is trying to cover a lot of different edge cases related to generating cache headers. It is complex. It tries to generate a consistent ETag for a serialized JSONApi response. When that response has includes, those included models are included in the ETag. When that response is a collection, all collection items’ cache keys are included in the ETag.

To use this module, include it in a JSONAPI::Serializer definition. Then, in your controller, use the stale? or fresh_when methods to set ETag and Last-Modified HTTP headers and respond to conditional GETs.

The module attempts to conform to Rails’ Recyclable Cache Keys specification, allowing serializers to be used as cache keys in the Rails cache as well.

rubocop:disable Metrics/LineLength