Skip to main content
Sonamu provides frequently used Cache-Control patterns as CachePresets. Using presets instead of writing configurations manually allows you to easily apply consistent and validated caching strategies.

CachePresets Overview

Complete Preset List

noStore

No cache storage

noCache

Revalidate every time

shortLived

1 minute cache

ssr

SSR optimized (10 seconds + SWR)

mediumLived

5 minute cache

longLived

1 hour cache

immutable

Permanent cache (static files)

private

Personalized data

Preset Details

noStore

Completely prohibits cache storage.

noCache

Stores cache but revalidates every time.
Benefits of no-cache:

shortLived

1 minute cache - Suitable for frequently changing data.

ssr

SSR page optimization - 10 second cache + Stale-While-Revalidate 30 seconds

mediumLived

5 minute cache - Suitable for rarely changing data.

longLived

1 hour cache - Suitable for static content.

immutable

Permanent cache - For static files with hash
Benefits of immutable:
  • Uses only cache without revalidation (fastest)
  • When file changes → new hash → new filename → automatic cache update

private

Personalized data - Different response per user
private vs public:
  • private: Cached only in browser (not on CDN)
  • public: Cached everywhere (browser + CDN)

Preset Comparison Table

Custom Configuration

If presets don’t fit, you can write your own configuration.

Global Handler

You can dynamically set Cache-Control for all requests.

Practical Usage

Strategy by API

SSR Pages

Precautions

Precautions when using presets:
  1. Presets are starting points: Customize as needed
  2. Only cache GET: Use noStore for POST, PUT, DELETE
  3. Private data must be private: Prevent CDN caching
  4. immutable only for hashed files: Must change filename to update

Next Steps

What is Cache-Control?

HTTP caching fundamentals

Using in APIs

Apply to @api decorators

Using in SSR

Apply to SSR pages