ObjectStackObjectStack

Http Cache

Http Cache protocol schemas

HTTP Metadata Cache Protocol

Implements efficient HTTP-level metadata caching with ETag support. Implements P0 requirement for ObjectStack kernel.

Caching in ObjectStack

HTTP Cache (api/http-cache.zod.ts) - This File

  • Purpose: Cache API responses at HTTP protocol level
  • Technologies: HTTP headers (ETag, Last-Modified, Cache-Control), CDN
  • Configuration: Cache-Control headers, validation tokens
  • Use case: Reduce API response time for repeated metadata requests
  • Scope: HTTP layer, client-server communication

Application Cache (system/cache.zod.ts)

  • Purpose: Cache computed data, query results, aggregations
  • Technologies: Redis, Memcached, in-memory LRU
  • Configuration: TTL, eviction policies, cache warming
  • Use case: Cache expensive database queries, computed values
  • Scope: Application layer, server-side data storage

Features

  • ETag-based conditional requests (HTTP 304 Not Modified)
  • Cache-Control directives
  • Metadata versioning
  • Selective cache invalidation

Industry alignment: HTTP Caching (RFC 7234), Salesforce Metadata API

See also: ../../system/cache.zod.ts for application-level caching

Source: packages/spec/src/api/http-cache.zod.ts

TypeScript Usage

import { CacheControlSchema, CacheDirective, CacheInvalidationRequestSchema, CacheInvalidationResponseSchema, CacheInvalidationTarget, ETagSchema, MetadataCacheRequestSchema, MetadataCacheResponseSchema } from '@objectstack/spec/api';
import type { CacheControl, CacheDirective, CacheInvalidationRequest, CacheInvalidationResponse, CacheInvalidationTarget, ETag, MetadataCacheRequest, MetadataCacheResponse } from '@objectstack/spec/api';

// Validate data
const result = CacheControlSchema.parse(data);

CacheControl

Properties

PropertyTypeRequiredDescription
directivesEnum<'public' | 'private' | 'no-cache' | 'no-store' | 'must-revalidate' | 'max-age'>[]Cache control directives
maxAgenumberoptionalMaximum cache age in seconds
staleWhileRevalidatenumberoptionalAllow serving stale content while revalidating (seconds)
staleIfErrornumberoptionalAllow serving stale content on error (seconds)

CacheDirective

Allowed Values

  • public
  • private
  • no-cache
  • no-store
  • must-revalidate
  • max-age

CacheInvalidationRequest

Properties

PropertyTypeRequiredDescription
targetEnum<'all' | 'object' | 'field' | 'permission' | 'layout' | 'custom'>What to invalidate
identifiersstring[]optionalSpecific resources to invalidate (e.g., object names)
cascadebooleanIf true, invalidate dependent resources
patternstringoptionalPattern for custom invalidation (supports wildcards)

CacheInvalidationResponse

Properties

PropertyTypeRequiredDescription
successbooleanWhether invalidation succeeded
invalidatednumberNumber of cache entries invalidated
targetsstring[]optionalList of invalidated resources

CacheInvalidationTarget

Allowed Values

  • all
  • object
  • field
  • permission
  • layout
  • custom

ETag

Properties

PropertyTypeRequiredDescription
valuestringETag value (hash or version identifier)
weakbooleanWhether this is a weak ETag

MetadataCacheRequest

Properties

PropertyTypeRequiredDescription
ifNoneMatchstringoptionalETag value for conditional request (If-None-Match header)
ifModifiedSincestringoptionalTimestamp for conditional request (If-Modified-Since header)
cacheControl{ directives: Enum<'public' | 'private' | 'no-cache' | 'no-store' | 'must-revalidate' | 'max-age'>[]; maxAge?: number; staleWhileRevalidate?: number; staleIfError?: number }optionalClient cache control preferences

MetadataCacheResponse

Properties

PropertyTypeRequiredDescription
dataanyoptionalMetadata payload (omitted for 304 Not Modified)
etag{ value: string; weak: boolean }optionalETag for this resource version
lastModifiedstringoptionalLast modification timestamp
cacheControl{ directives: Enum<'public' | 'private' | 'no-cache' | 'no-store' | 'must-revalidate' | 'max-age'>[]; maxAge?: number; staleWhileRevalidate?: number; staleIfError?: number }optionalCache control directives
notModifiedbooleanTrue if resource has not been modified (304 response)
versionstringoptionalMetadata version identifier

On this page