Handles HTTP ETag logic, If-Match/If-None-Match headers, and cache validation. Essential for preventing concurrency issues in REST APIs.

Install

mkdir -p .claude/skills/etag && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13388" && unzip -o skill.zip -d .claude/skills/etag && rm skill.zip

Installs to .claude/skills/etag

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Use this skill for any request involving HTTP ETags, conditional requests, or optimistic concurrency in REST APIs: implementing/explaining ETag headers, preventing lost updates, designing cache validation or conditional GET/PUT/DELETE, explaining If-Match, If-None-Match, 304 Not Modified, or 412 Precondition Failed, or any .NET/web/REST API project where resource versioning or concurrency is needed; always use when ETag, If-Match, If-None-Match, conditional requests, or optimistic concurrency are mentioned.
512 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Implement ETag headers for resource versioning
  • Prevent lost updates in REST APIs
  • Design cache validation using conditional requests
  • Explain If-Match and If-None-Match headers
  • Handle 304 Not Modified and 412 Precondition Failed responses

How it works

This skill guides the use of HTTP ETags as identifiers for specific resource versions to enable efficient caching and prevent simultaneous updates.

Inputs & outputs

You give it
A request involving HTTP ETags, conditional requests, or optimistic concurrency in REST APIs
You get back
Guidance, best practices, or explanations for ETag usage

When to use etag

  • Implementing optimistic concurrency for PUT operations
  • Configuring cache validation using If-None-Match
  • Debugging 412 Precondition Failed errors
  • Distinguishing between strong and weak ETag validators

About this skill

ETag Skill

This skill provides guidance and best practices for using HTTP ETags in REST APIs for cache validation and optimistic concurrency control.

What is an ETag?

  • The HTTP ETag (entity tag) response header is an identifier for a specific version of a resource.
  • ETags enable efficient caching and help prevent simultaneous updates from overwriting each other ("mid-air collisions").
  • If a resource changes, a new ETag value must be generated.

Syntax

ETag: "<etag_value>"
ETag: W/"<etag_value>"   # Weak validator
  • Strong ETags: Byte-for-byte identical content
  • Weak ETags: Semantically equivalent, but not byte-for-byte identical

Typical Patterns

  • Cache validation: Client sends If-None-Match with cached ETag; server replies 304 Not Modified if unchanged.
  • Optimistic concurrency: Client sends If-Match with ETag; server only updates if ETag matches current version, else 412 Precondition Failed.

Example: Avoiding Lost Updates

  1. Client GETs resource, receives ETag: ETag: "abc123"
  2. Client modifies resource, sends PUT with If-Match: "abc123"
  3. Server compares ETag; if matches, updates resource and returns new ETag. If not, returns 412 Precondition Failed.

Example: Caching

  1. Client GETs resource, receives ETag: ETag: "abc123"
  2. On next GET, client sends If-None-Match: "abc123"
  3. If unchanged, server returns 304 Not Modified (no body)

Related Headers

  • If-Match: Only perform operation if ETag matches
  • If-None-Match: Only perform operation if ETag does not match
  • If-Modified-Since, If-Unmodified-Since: Date-based alternatives
  • 304 Not Modified: Resource unchanged
  • 412 Precondition Failed: ETag did not match

Best Practices

  • Use strong ETags for byte-accurate validation; weak ETags for semantic equivalence

  • Always generate a new ETag when resource changes

  • Never reuse ETags for different content

  • ETag generation methods include:

    • Hash of resource content (collision-resistant preferred)
    • Hash of last modification timestamp
    • Revision number or version ID
  • ETags should be unique per resource version and content-coding aware (e.g., gzip vs. plain)

  • Avoid weak hash/checksum functions (e.g., weaker than CRC32)

  • For APIs, use ETags for update/delete concurrency, not just caching

  • In .NET, use middleware or manual header management to implement ETag logic

  • Always quote ETag values (e.g., "abc123"); use the optional W/ prefix for weak validators (e.g., W/"abc123").

  • Each representation (e.g., gzip, br, different formats) should have its own ETag.

  • For strictly versioned resources, use a version number as a strong ETag.

  • For non-versioned or compressed resources, use a hash of the content as a strong or weak ETag as appropriate.

  • If last-modified time is sufficient, consider using the Last-Modified header instead of ETag for simplicity.

Common Misuses

  • Unquoted ETag values (e.g., ETag: abc123)
  • English words or placeholders (e.g., ETag: default, ETag: $etagFile)
  • Template values not replaced (e.g., ETag: "MyCalculatedEtagValue")
  • ETags with spaces (e.g., ETag: "3/19/2017 6:35:34 PM")
  • Double-weak ETags (e.g., W/W/"abc123")
  • Not updating ETag after resource changes, causing stale content

Practical Example

GET /resource HTTP/1.1
Host: example.com

HTTP/1.1 200 OK
ETag: "ebeb4dbc1362d124452335a71286c21d"
Cache-Control: max-age=0, must-revalidate

# Client revalidates:
GET /resource HTTP/1.1
Host: example.com
If-None-Match: "ebeb4dbc1362d124452335a71286c21d"

HTTP/1.1 304 Not Modified

Caveats

  • Incorrect ETag handling (e.g., not updating after resource change) can cause clients to receive stale data
  • ETags can be abused for user tracking ("cookieless cookies"); be mindful of privacy implications

References


For more on ETag generation, strong/weak validation, and privacy, see the Wikipedia article and RFC 7232 Section 2.3.


For implementation details in .NET, Node.js, or other stacks, see the language/framework-specific guides or ask for code examples.

Limitations

  • ETags can be abused for user tracking

How it compares

This skill focuses on using ETags for both cache validation and optimistic concurrency control, which differs from simple date-based caching.

Compared to similar skills

etag side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
etag (this skill)04moNo flagsIntermediate
openrouter-streaming-setup127dReviewIntermediate
generating-grpc-services127dReviewAdvanced
openrouter-caching-strategy127dReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

aspnet-sse

aalmada

Implement Server-Sent Events (SSE) in ASP.NET Core using TypedResults.ServerSentEvents, SseItem<T>, and Channel-based pub/sub — including the notification service pattern, multi-instance Redis scaling, and the SseParser client. Trigger whenever the user writes, reviews, or asks about SSE, real-time

00

tunit

aalmada

Use this skill to write, review, and fix TUnit tests in .NET projects: for new test classes, assertions, data-driven tests, lifecycle hooks, debugging, migrating from xUnit/NUnit, choosing assertions, using Bogus, NSubstitute mocks, integration tests, or questions about parallelism and test ordering

00

bogus

aalmada

Generate realistic fake data for .NET projects using the Bogus library. Use for test data, database seeding, randomized object creation, and prototyping. Always prefer Bogus over hand-rolled random data or hardcoded test values. Trigger for any .NET test, data seeding, or sample data scenario. Use t

00

bunit

aalmada

Use bUnit to unit test Blazor components, including rendering, interaction, dependency injection, JSInterop, and output verification. Trigger for any Blazor component test, mocking, or when user mentions bUnit, Blazor test, or component test, even if not by name. Prefer this skill over hand-rolled t

00

refit

aalmada

Use Refit to define type-safe REST clients in .NET as C# interfaces backed by HttpClient — covering interface definition (HTTP verb attributes, parameter binding, return types), DI registration with AddRefitClient, DelegatingHandler pipelines for auth/headers/logging, error handling with IApiRespons

00

blazor

aalmada

Write, review, and fix Blazor Server components in the BookStore project — covering render modes (InteractiveServer), lifecycle with IDisposable cleanup, DI via @inject/[Inject], ReactiveQuery<T> for SSE-driven data loading, MudBlazor forms/dialogs/tables, tenant-aware services, and AuthorizeView gu

00

You might also like

openrouter-streaming-setup

jeremylongshore

Implement streaming responses with OpenRouter. Use when building real-time chat interfaces or reducing time-to-first-token. Trigger with phrases like 'openrouter streaming', 'openrouter sse', 'stream response', 'real-time openrouter'.

111

generating-grpc-services

jeremylongshore

Generate gRPC service definitions, stubs, and implementations from Protocol Buffers. Use when creating high-performance gRPC services. Trigger with phrases like "generate gRPC service", "create gRPC API", or "build gRPC server".

13

openrouter-caching-strategy

jeremylongshore

Implement response caching for OpenRouter efficiency. Use when optimizing costs or reducing latency for repeated queries. Trigger with phrases like 'openrouter cache', 'cache llm responses', 'openrouter redis', 'semantic caching'.

12

mcp-builder

anthropics

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

136215

telegram-bot-builder

davila7

Expert in building Telegram bots that solve real problems - from simple automation to complex AI-powered bots. Covers bot architecture, the Telegram Bot API, user experience, monetization strategies, and scaling bots to thousands of users. Use when: telegram bot, bot api, telegram automation, chat bot telegram, tg bot.

106130

stripe-integration

wshobson

Implement Stripe payment processing for robust, PCI-compliant payment flows including checkout, subscriptions, and webhooks. Use when integrating Stripe payments, building subscription systems, or implementing secure checkout flows.

48165

Search skills

Search the agent skills registry