Home/Guides/Ephemeral Storage
System Design

The Mechanics of Ephemeral Auto-Purge: Just-in-Time Deletion vs Background Crons

A technical walkthrough of dual-layer deletion mechanisms: how scheduled background cron workers combine with Just-in-Time access validation to guarantee zero residual traces.

By Locky Architecture Team•6 min read•Updated 2026-10-19•Ephemeral Storage

Why Single-Layer Deletion Strategies Fail

Many applications claiming to offer 'disappearing files' rely on a single background worker that runs periodically (e.g., once every hour or midnight). If a file expires at 12:01 PM and the cleaner runs at 1:00 PM, the file remains accessible for 59 minutes past its promised expiration.

Conversely, relying solely on access-time deletion means that if nobody opens the link again, the abandoned file lingers in storage indefinitely.

Key Architectural Takeaways

  • Single-layer deletion leaves window vulnerabilities or creates orphaned storage objects.
  • Just-in-Time (JIT) validation calculates absolute Epoch elapsed time upon every request.
  • Scheduled cron sweeps systematically clean abandoned vaults that were never visited.

Layer 1: Just-in-Time (JIT) Validation

Every media object in Locky stores an immutable UTC Epoch timestamp in its metadata header (created-at). Whenever a viewer accesses a vault URL or submits a PIN verification request, the server executes: elapsed = Date.now() - createdAt.

If elapsed >= 86,400,000 milliseconds (24 hours), the server immediately executes an asynchronous delete command to S3/R2 storage and responds with HTTP 404 / 410. Access is denied on the exact millisecond of expiration.

Advertisement

Layer 2: Background Garbage Collection

To clean up vaults that were uploaded but never opened, automated background cron jobs inspect storage buckets periodically. The worker lists object metadata headers, identifies all objects with elapsed >= 24 hours, and performs bulk deletion sweeps.

This dual-layer mechanism guarantees zero orphaned files and enforces strict compliance with our zero-retention pledge.

Try Zero-Knowledge Ephemeral Sharing

Need to share a photo or video privately without permanent digital footprint? Locky strips location metadata client-side in your browser, locks media behind a 4-digit numeric PIN, and guarantees automatic self-destruction in 24 hours.