generators-http-cache

Generate an HTTP caching layer for Swift APIClient with ETag conditional requests.

4|1|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill generators-http-cache
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generators-http-cache
Source: https://github.com/AutisticAF/claude-code-apple-dev-plugin/tree/main/skills/generators-http-cache
Command: npx skills add https://github.com/AutisticAF/claude-code-apple-dev-plugin --skill generators-http-cache

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Many Swift apps perform redundant network requests, lack per-endpoint cache control, and provide poor offline user experience. This Skill generates a transparent, production-ready HTTP caching layer to reduce API calls, save bandwidth, and enable robust offline fallback with conditional requests.

Core Features & Use Cases

  • Cache-Control parsing & policy: Respect server directives, support max-age, stale-while-revalidate, and per-endpoint overrides.
  • ETag / conditional requests: Add If-None-Match and If-Modified-Since handling to minimize bandwidth with 304 responses.
  • Disk-backed LRU storage & reachability: Provide in-memory + disk caching with eviction and NWPathMonitor-based offline fallback for smooth UX.
  • Use Case: Add caching to a Swift APIClient to return cached feed data immediately while revalidating in the background and serving stale results when offline.

Quick Start

Add a disk-backed HTTP caching layer with Cache-Control parsing, ETag conditional requests, stale-while-revalidate behavior, and offline fallback to my Swift APIClient.

Frequently Asked Questions about generators-http-cache

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add HTTP caching with ETag and Cache-Control to my Swift APIClient?

You can add HTTP caching to your Swift APIClient by integrating a decorator-style caching layer that parses Cache-Control directives and handles ETag conditional requests. This generates per-endpoint caching policies to reduce redundant network calls.

What is stale-while-revalidate behavior for offline fallback in iOS apps?

Stale-while-revalidate behavior serves cached data immediately while backgrounding a network revalidation request. When combined with NWPathMonitor reachability detection, it provides offline fallback by serving stale cached results when network connectivity is unavailable.

Can I implement disk-backed LRU cache eviction for HTTP responses on macOS 13?

Yes, disk-backed LRU cache eviction is supported on macOS 13 and iOS 16 with Swift 5.9+. The caching layer combines in-memory and disk storage to evict stale HTTP responses automatically based on least-recently-used policies.

How does NWPathMonitor integrate with HTTP caching for Swift networking?

NWPathMonitor integrates with HTTP caching by monitoring network reachability and triggering offline fallback behavior. When the network is unavailable, the cache layer serves stored responses directly, ensuring continuous app functionality.

What's the best way to handle 304 Not Modified responses in a Swift HTTP client?

Handling 304 Not Modified responses requires adding If-None-Match and If-Modified-Since headers to conditional requests. The caching layer intercepts these responses to minimize bandwidth while continuing to serve valid cached content.

Do I need a specific deployment target to use disk-backed HTTP caching in Swift?

Yes, disk-backed HTTP caching requires Swift 5.9+ and deployment targets of iOS 16 or macOS 13 or later. These minimum versions provide the foundational networking APIs needed for Cache-Control parsing and NWPathMonitor integration.