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'm a lawyer who launched an AI contract tool on Product Hunt today — here's what building it as a non-technical founder actually felt like User Avatar 151 comments Never hire an SEO Agency for your Saas Startup User Avatar 74 comments A simple way to keep AI automations from making bad decisions User Avatar 65 comments “This contract looked normal - but could cost millions” User Avatar 54 comments 👉 The most expensive contract mistakes don’t feel risky User Avatar 41 comments We automated our business vetting with OpenClaw User Avatar 34 comments