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
Feature | Description |
---|---|
config_file | Enables loading from a TOML config file |
last_modified | Enables last-modified timestamp support |
etag | Enables ETag generation and resolution |
redis | Enables Redis-based storage backend |
§Modules
api
- Abstracted types and logic for the invalidaton apiconfig
- Load and build cache configurationetag
(optional) - ETag generation and combinationmapping
- Path-to-tag mapping logicmeta
- Logic for setting and validation the headersruntime
- Basic composition of the entrypointstore
- 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.