Optimistic CRUD With ETag

Reject outdated PUT requests using ETag headers and version integers.

Updated Apr 30, 2026
One-click install
npx skills add https://github.com/bytetalent/docs --skill optimistic-crud-with-etag
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Optimistic CRUD With ETag
Source: https://github.com/bytetalent/docs/tree/main/skills/paths/optimistic-crud-with-etag
Command: npx skills add https://github.com/bytetalent/docs --skill optimistic-crud-with-etag

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Ensures data integrity during concurrent edits, preventing overwrites and conflicts.

Core Features & Use Cases

  • Versioning: Each entity maintains an integer version number to track changes.
  • ETag Headers: API returns an ETag for each entity, which the client uses on PUT requests.
  • Concurrency Handling: Returns a '412 Precondition Failed' when versions do not match, prompting a re-fetch.

Quick Start

Apply the Optimistic CRUD With ETag pattern to any entity in your Next.js or Expo app that can be edited concurrently.

Frequently Asked Questions about Optimistic CRUD With ETag

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

FAQPage Schema
How do I prevent lost updates during concurrent edits in my API?

To prevent lost updates in concurrent edits, implement optimistic concurrency using integer versioning and ETag headers. The API issues an ETag per entity, and clients must include it on PUT requests to avoid silently overwriting changes made by others.

What is optimistic concurrency control and how does an ETag work?

Optimistic concurrency control using an ETag tracks entity versions to detect conflicts. The API returns an ETag header representing the current version, which clients send back on updates; mismatched versions trigger a 412 Precondition Failed error to prevent overwrites.

How do I implement optimistic concurrency with ETag headers in Next.js?

To implement optimistic concurrency in Next.js, maintain a version integer on each entity and return it as an ETag header. Clients send this ETag on PUT requests, and the server rejects updates with a 412 Precondition Failed status if the version is outdated.

Does optimistic concurrency with ETag work for Expo mobile apps?

Optimistic concurrency with ETag works for Expo apps by applying the same version and ETag header pattern. The client reads the ETag from API responses and includes it in subsequent PUT requests to ensure concurrent edits do not cause data corruption.

Why does my PUT request fail with 412 Precondition Failed?

A PUT request fails with 412 Precondition Failed when the ETag header sent by the client does not match the current entity version on the server. This rejection mechanism prompts the client to re-fetch the latest data before attempting another update.