1
2 Comments

Building a URL Shortener sounds easy... until you add dynamic, cached QR codes. 🏗️

Hey IH 👋

I’m building NanoURL, a modern link management SaaS. On the surface, a URL shortener sounds like a weekend project, but I quickly realized that building it for scale is a different beast.

I just wrapped up the core backend engine (Spring Boot + PostgreSQL) and spent a lot of time engineering the QR Code generation. Instead of just saving static Base64 image strings to the database (which would eventually bloat the DB to a crawl), I opted for a dynamic, cached approach:

Dynamic Generation: The backend generates QR codes on the fly. Free users get a PNG with a "Powered by NanoURL" watermark automatically applied via Java Graphics2D.

Pro SVG Support: Premium users get crisp, infinitely scalable SVGs without watermarks (perfect for printing on business cards).

Redis Caching: To keep it blazing fast, the Spring Boot endpoint (@Cacheable) caches the generated bytes in Redis. The React frontend simply requests the image URL, and it loads instantly.

It took a bit of architecture planning to get the browser caching (maxAge(24, TimeUnit.HOURS)) and Redis caching perfectly synced, but the performance is incredible.

Question for the community: When building features that generate media (like images or PDFs), do you prefer generating on the fly with a caching layer, or pre-generating and dumping them into AWS S3?

on March 29, 2026
  1. 1

    to answer your question — i go with on-the-fly generation + caching every time. pre-generating to S3 means you're paying for storage of stuff that might never get accessed, and you need a whole pipeline to regenerate when something changes. with redis caching you get the best of both worlds. i do something similar with my SEO reports — generate the PDF scan results on demand, cache them for 24h, and let them expire naturally. the SVG vs PNG tiering for free/pro is a smart monetization angle too.

    1. 1

      Thank you for sharing your approach! 🙌 I completely agree that on-the-fly generation combined with caching offers a more efficient solution, especially when it comes to managing costs and resources. By caching generated content for a limited time, like your SEO reports, we can ensure that we serve up-to-date information without the overhead of unnecessary storage. 💡 Keep up the great work!

Trending on Indie Hackers
I launched on Product Hunt today with 0 followers, 0 network, and 0 users. Here's what I learned in 12 hours. User Avatar 122 comments The most underrated distribution channel in SaaS is hiding in your browser toolbar User Avatar 106 comments I gave 7 AI agents $100 each to build a startup. Here's what happened on Day 1. User Avatar 70 comments A simple LinkedIn prospecting trick that improved our lead quality User Avatar 60 comments I changed AIagent2 from dashboard-first to chat-first. Does this feel clearer? User Avatar 39 comments Show IH: RetryFix - Automatically recover failed Stripe payments and earn 10% on everything we win back User Avatar 32 comments