@agrodt/astro-redis-cache-provider
    Preparing search index...

    @agrodt/astro-redis-cache-provider

    @agrodt/astro-redis-cache-provider

    CI Coverage Status npm version License: MIT npm downloads

    Custom Redis cache provider for Astro route caching, powered by node-redis.

    Caution

    Disclaimer: This project is 102% generated by an LLM. The author assumes absolutely no responsibility for any consequences of using it - especially, but not limited to, the mysterious harm that may befall nearby kittens once you deploy this in production. Proceed at your own risk!

    pnpm add @agrodt/astro-redis-cache-provider
    

    node-redis already comes as a dependency of this package. You only need a reachable Redis server.

    // astro.config.mjs
    import { defineConfig } from "astro/config";
    import { redisCache } from "@agrodt/astro-redis-cache-provider/config";

    export default defineConfig({
    experimental: {
    cache: {
    provider: redisCache({
    url: () => process.env.REDIS_URL,
    keyPrefix: "astro:cache",
    }),
    },
    },
    });
    type RedisCacheProviderOptions = {
    url?: string | (() => string | undefined);
    keyPrefix?: string;
    revalidateLockTtl?: number;
    ignoredVaryHeaders?: Iterable<string>;
    query?: {
    include?: string[];
    exclude?: string[];
    sort?: boolean;
    };
    };
    • url: Redis URL string or runtime factory (() => string | undefined), for example redis://localhost:6379 or () => process.env.REDIS_URL.
    • keyPrefix: Prefix for all Redis keys. Default: astro:cache.
    • revalidateLockTtl: Lock lifetime in seconds for stale background revalidation. Default: 30.
    • ignoredVaryHeaders: Additional Vary headers to ignore during cache matching (for example ["cookie"]). set-cookie is always ignored.
    • query: Same query normalization semantics as Astro memory provider (include/exclude are mutually exclusive).

    See example for a runnable Astro app that demonstrates MISS/HIT behavior and manual invalidation.