Lightweight, privacy-first link shortener backed by your Cloudflare Worker and Key-Value edge storage. Instant redirects, custom vanity back-halves, and intelligent 20-day inactivity auto-deletion.
// 1. In Cloudflare Dashboard -> msstore-worker -> Settings -> Variables -> KV Bindings:
// Bind your link KV as: env.LINK_KV
// 2. Add this block to your worker's fetch(request, env) handler:
if (request.method === "POST" && url.pathname === "/api/shorten") {
const { url: dest, slug, ttl } = await request.json();
const kvOpts = ttl ? { expirationTtl: Number(ttl) } : {};
await env.LINK_KV.put(`url:${slug}`, JSON.stringify({
destination: dest, createdAt: Date.now(), lastAccessed: Date.now(), clicks: 0
}), kvOpts);
return new Response(JSON.stringify({ success: true, slug, shortUrl: `${url.origin}/s/${slug}` }), {
headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*" }
});
}
if (request.method === "GET" && url.pathname.startsWith("/s/")) {
const slug = url.pathname.replace("/s/", "").trim();
const raw = await env.LINK_KV.get(`url:${slug}`);
if (!raw) return new Response("Link expired or not found", { status: 404 });
const data = JSON.parse(raw);
data.clicks = (data.clicks || 0) + 1;
data.lastAccessed = Date.now();
await env.LINK_KV.put(`url:${slug}`, JSON.stringify(data), { expirationTtl: 1728000 }); // renews 20-day TTL!
return Response.redirect(data.destination, 302);
}
| Short Link | Destination URL | Expiration Policy | Clicks | Created | Actions |
|---|
Input any long link, document URL, portfolio gallery, or photo website asset into the destination box.
Keep the default 20-Day Inactive Cleanup to automatically purge dead links, or choose permanent or disposable modes.
Your short link is stored in Cloudflare KV edge servers worldwide, serving <15ms 301/302 redirects with zero cold starts.
Traditional SQL shorteners query distant centralized databases. Cloudflare Workers KV reads key-value pairs directly from local edge memory closest to your visitor.
Never pay for abandoned URLs. If a link receives zero visits over 20 consecutive days, KV automatically expires it. Active links that receive visits keep renewing their 20-day lease automatically.
Share your existing photo website KV database with 100% safety. Links are stored under isolated key prefixes (url:slug), ensuring images and short links never conflict.
| Feature | Legacy Shorteners (Bitly / TinyURL) | ShiftLink KV Edge |
|---|---|---|
| Redirect Latency | 120ms – 350ms (Centralized server query) | <15ms (Cached at global edge) |
| Unused Link Auto-Purge | None (clutters database forever or charges fees) | Automatic 20-Day Inactive Rolling TTL |
| Privacy & Tracking | Third-party ad trackers, cookies, redirects | Zero cookies, zero ad trackers, local-first |
| Database Architecture | Heavy relational SQL / NoSQL database cluster | O(1) Edge Key-Value Storage |
| QR Code Generation | Watermarked / Paywalled HD export | 100% Free Instant HD PNG & SVG |
lastAccessed timestamp and pushes the KV expiration out by another full 20 days. Popular, actively shared links will never expire.
url:my-slug vs photo:image_102). You can also bind a dedicated secondary KV namespace in your wrangler.toml configuration if you prefer 100% isolation.