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?
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.
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!