
Adding a self-destructing timer to a disposable email service
I run 15minutemail.com. The pitch is simple: you get an email inbox that lasts 15 minutes. When time's up, everything gets deleted. But if you need more time, you can extend it. Sounds trivial. It mostly was, except for the parts that weren't. The timer isn't just a countdown The obvious approach is to start a setTimeout on the client and show a countdown. That works for display purposes but it doesn't actually control anything. The real TTL lives on the server. When a user opens the site, the backend creates a session with an expires_at timestamp set to now + 15 minutes. This timestamp is stored in SQLite alongside the temporary email address. The client gets the expiration time in the API response and renders a countdown from it. If the user closes the tab and comes back, the timer picks up where it left off because it's based on the server timestamp, not a client-side counter. No cheating by refreshing the page. The cleanup job A background job runs every 60 seconds. It queries SQLi
Continue reading on Dev.to Webdev
Opens in a new tab
.jpg&w=1200&q=75)



