SimonCropp/Delta
SimonCropp/Delta has 1,522 GitHub stars and 38 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 04:24 UTC. Last push 2026-10-27.
An approach to implementing a 304 Not Modified leveraging DB change tracking
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Original
Delta
Delta is an approach to implementing a 304 Not Modified leveraging DB change tracking.
The approach uses a last updated timestamp from the database to generate an ETag. All dynamic requests then have that ETag checked/applied.
This approach works well when the frequency of updates is relatively low. In this scenario, the majority of requests will leverage the result in a 304 Not Modified being returned and the browser loading the content its cache.
Effectively consumers will always receive the most current data, while the load on the server is reduced.
See Milestones for release notes.
Sponsors
Entity Framework Extensions
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
Developed using JetBrains IDEs
Jump to specific docs
- SQL Server Docs when using SQL Server SqlClient
- PostgreSQL Docs when using PostgreSQL Npgsql
- EF with SQL Server Docs when using the SQL Server EF Database Provider
- EF with PostgreSQL Docs when using the PostgreSQL EF Database Provider
Assumptions
Frequency of updates to data is relatively low compared to reads
304 Not Modified Flow
graph TD
Request
NoCache{Has no-cache<br/>in Cache-Control?}
HasMaxAge{Has max-age<br/>or max-stale<br/>in Cache-Control?}
CacheValid{Cached timestamp<br/>within allowed<br/>staleness?<br/>Considers min-fresh}
FreshTimestamp[Get fresh timestamp<br/>from SQL]
UseCached[Use cached timestamp]
CalculateEtag[Calculate current ETag<br/>based on timestamp<br/>from web assembly and SQL]
IfNoneMatch{Has<br/>If-None-Match<br/>header?}
EtagMatch{Current<br/>Etag matches<br/>If-None-Match?}
AddETag[Add current ETag<br/>to Response headers]
304[Respond with<br/>304 Not-Modified]
Request --> NoCache
NoCache -->|Yes| FreshTimestamp
NoCache -->|No| HasMaxAge
HasMaxAge -->|Yes| CacheValid
HasMaxAge -->|No| FreshTimestamp
CacheValid -->|Yes| UseCached
CacheValid -->|No| FreshTimestamp
UseCached --> CalculateEtag
FreshTimestamp --> CalculateEtag
CalculateEtag --> IfNoneMatch
IfNoneMatch -->|Yes| EtagMatch
IfNoneMatch -->|No| AddETag
EtagMatch -->|No| AddETag
EtagMatch -->|Yes| 304
DB implementation
Implementation is specific to the target database
ETag calculation logic
The ETag is calculated from a combination several parts
{AssemblyWriteTime}-{DbTimeStamp}-{Suffix}
AssemblyWriteTime
The last write time of the web entry point assembly
var webAssemblyLocation = Assembly.GetEntryAssembly()!.Location;
AssemblyWriteTime = File.GetLastWriteTime(webAssemblyLocation).Ticks.ToString();
DB timestamp
Timestamp calculation is specific to the target database
Suffix
An optional string suffix that is dynamically calculated at runtime based on the current HttpContext.
var app = builder.Build();
app.UseDelta(suffix: httpContext => "MySuffix");
Combining the above
internal static string BuildEtag(string timeStamp, string? suffix)
{
if (suffix == null)
{
return $"\"{AssemblyWriteTime}-{timeStamp}\"";
}
return $"\"{AssemblyWriteTime}-{timeStamp}-{suffix}\"";
}
Usage
Delta has two approaches to usage:
Raw DbConnection approach
Delivers functionality using DbConnection and DbTransaction.
NuGet: Delta
Documentation is specific to choice of database:
- SQL Server Docs when using SQL Server SqlClient
- PostgreSQL Docs when using PostgreSQL Npgsql
Entity Framework approach
Delivers functionality using Entity Framework.
NuGet: Delta.EF
Documentation is specific to choice of database:
- EF with SQL Server Docs when using the SQL Server EF Database Provider
- EF with PostgreSQL Docs when using the PostgreSQL EF Database Provider
Timestamp caching via request Cache-Control
By default, Delta queries the database on every GET request to retrieve the current timestamp. Clients can opt into timestamp caching by sending Cache-Control request headers, allowing Delta to skip the database round-trip when a recent enough cached timestamp exists.
Supported directives:
max-age=N— accept a cached timestamp up to N seconds oldmax-stale=N— accept a cached timestamp up to N seconds oldmax-stale(no value) — accept any cached timestamp regardless of age
If both max-age and max-stale are present, the larger (more permissive) value is used.
Requests without these directives always query the database (existing behavior).
Example request headers:
Cache-Control: max-age=5
Cache-Control: max-stale
UseResponseDiagnostics
Response diagnostics is an opt-out feature that includes extra log information in the response headers. Consider disabling in production to avoid adding diagnostic headers to every response.
Disable by setting UseResponseDiagnostics to false at startup:
DeltaExtensions.UseResponseDiagnostics = false;
Response diagnostics headers are prefixed with Delta-.
Example Response header when the Request has not If-None-Match header.

Verifying behavior
The behavior of Delta can be verified as follows:
- Open a page in the site
- Open the browser developer tools
- Change to the Network tab
- Refresh the page.
Cached responses will show as 304 in the Status:

In the headers if-none-match will show in the request and etag will show in the response:

Ensure cache is not disabled
If disable cache is checked, the browser will not send the if-none-match header. This will effectively cause a cache miss server side, and the full server pipeline will execute.

Certificates and Chromium
Chromium, and hence the Chrome and Edge browsers, are very sensitive to certificate problems when determining if an item should be cached. Specifically, if a request is done dynamically (type: xhr) and the server is using a self-signed certificate, then the browser will not send the if-none-match header. Reference. If self-signed certificates are required during development in lower environment, then use FireFox to test the caching behavior.
Programmatic client usage
Delta is primarily designed to support web browsers as a client. All web browsers have the necessary 304 and caching functionally required.
In the scenario where web apis (that support using 304) are being consumed using .net as a client, consider using one of the below extensions to cache responses.
Icon
Estuary designed by Daan from The Noun Project.
Explore related projects
affaan-m/ECC
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
299,246 starsNousResearch/hermes-agent
The agent that grows with you
261,548 starsmultica-ai/andrej-karpathy-skills
A single CLAUDE.md file to improve Claude Code behavior, derived from Andrej Karpathy's observations on LLM coding pitfalls.
230,650 starsfirecrawl/firecrawl
Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
199,551 stars
