Pangea is a Hexarc engine designed to cache static web resources. It sits between Hyperion and the Aeon database; it is also capable of basic transformations, such as image rescaling and recompression.

Basic Protocol

  1. Hyperion sends a message to Pangea asking for a specific Aeon filespec.
  2. Pangea looks up the filespec in its cache and gets the modifiedOn timestamp.
  3. Pangea sends the timestamp to Aeon asking for a newer version.
  4. If Aeon does not have a newer version, Pangea sends the version in its cache (often in memory) back to Hyperion.
  5. If Aeon has a newer version, Pangea stores the version in its cache and returns it to Hyperion.

Transformations

Pangea can perform certain standard transformation on the data. These transformations are specified by its callers (Hyperion) and applied by Pangea before adding the file to its cache. The transformations become part of the identifier.

Pangea can perform the following transformations:

  • Image scaling: Callers specify a maximum width and height and Pangea will rescale images to fit (preserving aspect ratio).
  • Image cropping
  • Minify/obfuscate JavaScript.

Implementation

For each resource we generate a unique identifier based on Aeon filespec and transforms. The first-level cache is an in-memory cache that hashes identifiers to a timestamp, size, and data.

For raw files, the timestamp is the modified time of the file in Aeon. For transformed resources, it is the modified time of the original file (the source of the transform).

The first-level cache has a quota. On a cache miss, after we've returned the data to Hyperion, we check to see if the cache is full. If so, we discard the least recently accessed files.