I'm new to web development, especially on the backend, and I've been tasked with creating an auto-translation feature for a small nonprofit's website. The budget is tight, so I'm looking for cost-effective solutions. I've managed to create a functional feature, but I'm worried about the cost of using the Google Translate API. I've implemented client-side caching to help returning users, but I'm struggling with server-side caching.
Currently, my Cloud Run server caches translations but it shuts down the container after a short period of inactivity, which isn't ideal for our low-traffic site. I've tried using Firebase and Google Cloud Storage, but I seem to be misunderstanding the permissions or how to set them up correctly. The Cloud Console feels a bit daunting, and I'm eager to learn how to manage this effectively. I'd really appreciate any best practices or resources that could guide me in implementing this server-side caching successfully. I want to enhance accessibility for this nonprofit, so any help would be fantastic!
5 Answers
Consider whether the translations really need to be dynamic. If the content changes infrequently, it might be better to cache translations in your storage or version control. That way, you can run a script to update translations and store them in your repository, eliminating the need for a long-running service entirely.
It might also be beneficial to look into edge caching with a CDN like Cloudflare, which has localized functionality and offers free plans. This could help your site serve translations more efficiently for users from different regions.
Last time I tried Google Cloud, it was super pricey. Just a heads up! Make sure you keep an eye on costs as you build the translation feature.
Don't forget that Google Chrome already has a built-in translation feature for pages not in the user's native language, which might cover a good chunk of your audience. It has a huge market share, so users may not even need additional features from your site.
If you're after persistent caching, I recommend using Redis or its open-source alternative, Valkey. They'll help you avoid the issues with your container shutting down too quickly.

Related Questions
How to Build a Custom GPT Journalist That Posts Directly to WordPress
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads