Crate http_cache_tags_core

Source
Expand description

Experimental: Alpha Release

This crate is in early development. APIs are unstable and may change without notice. Not recommended for production use yet.

Core components for HTTP cache tagging and validation.

This crate provides foundational types and utilities for implementing HTTP caching using tag-based cache invalidation and metadata resolution.

Note: This crate is not intended for direct standalone usage. Instead, use the higher-level http_cache_tags crate, which provides integrations with popular web frameworks and middleware.

§Features

  • Config File (config_file feature): Load cache config from a TOML file.
  • ETag Support (etag feature): Generate and manage weak ETags.
  • Last-Modified Support (last_modified feature): Track modification timestamps.
  • Redis Integration (redis feature): Persist metadata in a Redis backend.
  • Route-to-Tag Mapping: Map request paths to cache tags for granular invalidation.

§Example

use http_cache_tags_core::{config::CacheConfig, runtime::CacheRuntime};

let config = CacheConfig::builder()
    .invalidation_api_route("/_invalidate")
    .invalidation_api_secret("my-secret")
    .add_route_mapping("/blog/*", vec!["blog", "media"])
    .add_route_mapping("/user/*", vec!["users"])
    .build();

let cache_runtime = CacheRuntime::builder().config(config).build();

§Optional Features

FeatureDescription
config_fileEnables loading from a TOML config file
last_modifiedEnables last-modified timestamp support
etagEnables ETag generation and resolution
redisEnables Redis-based storage backend

§Modules

  • api - Abstracted types and logic for the invalidaton api
  • config - Load and build cache configuration
  • etag (optional) - ETag generation and combination
  • mapping - Path-to-tag mapping logic
  • meta - Logic for setting and validation the headers
  • runtime - Basic composition of the entrypoint
  • store - In-memory and Redis cache stores

§Integration

This crate is designed to be embedded in server-side caching systems. For full integration with HTTP servers (e.g., Actix, Axum), use the http_cache_tags umbrella crate.

Modules§

api
REST API integration logic for cache invalidation.
config
Configuration types for cache behavior.
etag
ETag-based cache validation.
mapping
Route-to-Cache Tag Mapping
meta
Cache metadata resolution and freshness validation.
runtime
Runtime integration for HTTP cache tagging.
store
Cache storage backends.