Use ETags to Cut License Refresh Downloads

ملخص

Pixel’s announcement explains how ETags and If-None-Match can make license refreshes more efficient. When a license has not changed, the service returns 304 Not Modified with no response body, avoiding repeated signed-lease downloads and RSA verification while preserving cached offline validation.

DEV Community

Conditional license refresh with ETag: stop re-downloading a license that has not changed

A Keyright client does not call home on every license check. It activates once, caches the signed lease, and from then on every Validate() is a local, offline operation against the embedded public key. What does talk to the issuing service is the background refresh: on a timer — typically every few minutes to a few hours — the SDK re-fetches the lease so that a renewal, an entitlement change, or a revocation is picked up without waiting for a restart. Here is the thing about that refresh loop: almost every iteration of it is a no-op. A license is a slow-moving resource. It changes when someone renews, upgrades, transfers a seat, or gets revoked — events that happen days or weeks apart. Between those events, a client that refreshes every five minutes asks the service "what is the current state of this license?" hundreds of times and gets back byte-for-byte the same signed lease every single time. Each of those answers is a full response body the service serialized and signed, pushed over the network, that the client then base64-decoded and ran an RSA verify over — all to confirm what it already knew. HTTP has had the right primitive for this since 1999. It is the conditional GET, built on the ETag response header and the If-None-Match request header, and wiring it into the refresh path turns the common case — nothing changed — into a headers-only round trip that returns 304 Not Modified with an empty body. Key takeaway: Have your issuing service stamp every license response with a strong ETag derived from the license's version and signature. Have the SDK remember that tag and send it back as If-None-Match on the next refresh. When nothing has changed the service answers 304 Not Modified with no body, the client keeps its cached lease untouched, and you have replaced a full signed-payload download plus a signature verify with a few hundred bytes of headers — without ever letting a stale cache hide a revocation. What a license fetch looks like today Strip the SDK away and a refresh is an ordinary HTTP GET. The client asks for the current lease for a key; the service returns the signed document. GET /v1/licenses/current HTTP/1.1
Host: keyright.example.com
X-Keyright-Product: acme-suite
Authorization: Bearer AK-9f3c… ← the activation token from the initial handshake

HTTP/1.1 200 OK
Content-Type: application/vnd.keyright.lease+json
Content-Length: 1184

{ "lease": "eyJhbGciOi…", "signature": "MEUCIQ…", "edition": "pro", "expiresAt": "2027-01-01T00:00:00Z" }
That lease blob is the canonical, signed payload the client verifies offline. At a kilobyte-plus a shot, times a fleet of clients, times a refresh every few minutes, times the fact that the content is identical between license events, it is pure waste. The service did real work to produce a body nobody needed. The ETag: a fingerprint the client can quote back An ETag ("entity tag") is an opaque validator the server attaches to a response. Its only contract is this: if two responses for the same URL carry the same ETag, their representations are identical; if the resource changes, the ETag must change. The client treats it as a black box — it never parses it — and simply quotes it back on the next request to ask "do you still have exactly this?". For a license, you do not want to hash the whole response body to produce the tag (that works, but it costs a hash over the payload on every request). You already have two fields that change if and only if the license changes: a monotonic version the issuing service bumps on every mutation, and the signature itself. Combine them into a strong validator: ETag: "v47-3b9a1f" ← license version 47, first bytes of the signature, strong tag
This is a strong ETag (no W/ prefix), which is the correct choice here: a conditional request should match only when the bytes are genuinely identical, because the client is going to skip verifying a new signature on a match. A weak tag (W/"…"), which only promises semantic equivalence,...
Use ETags to Cut License Refresh Downloads
Powered by Readybot.io

الأحدث من Pixel

Incident Response: Look Beyond the Red Alert

Pixel’s DEV Community announcement explores how teams can fixate on one failing service while overlooking the real cause of an outage, such as a full …

Sach: AI Fact-Checks WhatsApp Forwards in India

Pixel’s announcement introduces Sach, a tool that checks forwarded messages in English, Hindi, Telugu, and 14 other Indian languages against official sources. It gives cited …

Java 25 Removes SecurityManager: What to Fix

Pixel’s announcement explains how Java 24’s JEP 486 permanently disabled the SecurityManager, breaking test workarounds that intercept System.exit. It recommends returning exit codes or throwing …

Why a Java HPA Got Stuck at 20 Kubernetes Pods

Pixel shares how a Spring Boot pricing service autoscaled to 20 Kubernetes pods and stayed there because the JVM retained committed heap memory after traffic …