0

Here's the thing: we have a website which has some i18n. Translations are maintained in DB and manually exported into JSON files which are consumed by our SPA one time on load.

Now I have the following problem to solve: I want to put those i18n JSON files to some CDN and when someone makes updates in database, I would like JSON files to be regenerated automatically and get those uploaded to CDN.

My current thinking is to make Trigger in DB (PostgreSQL) which will send NOTIFY on data change and some service which will listen for that. After this signal it will upload actual JSON to CDN,

Could anyone propose alternative approach?

4
  • Is there a service layer in front of your database, or are changes made directly in the database?
    – Samuel
    Aug 9, 2017 at 21:03
  • What's wrong with the approach you proposed? Aug 9, 2017 at 22:44
  • @RobertHarvey nothing, just want to know if someone had similar experience and could come up with alternatives. Aug 10, 2017 at 9:20
  • @Samuel Thanks, a good question. There is not for now, but there will be some UI/Service which will allow maintaining this. Indeed it could be an option to add one more step to UI/Service which will push data to CDN after save is successfully performed Aug 10, 2017 at 9:28

1 Answer 1

1

First of all, you need a way to serve the data over HTTP, e.g. a web server accessing your database. Then, you need to use the HTTP cache control headers to ensure that any proxied data is refreshed correctly. To start with, set Last-Modified correctly.

How often are your updates? Are they on a schedule? If they are totally random, use ETag. Otherwise, set Expires appropriately.

HTTP, used correctly, is awesome.

2
  • That's exactly what CDN is for here, but the question is not about how to serve files via http ;) Aug 28, 2017 at 17:31
  • @AlexanderEfimov Many CDNs will request your files over HTTP and use the returned Cache-Control headers to automatically update them as needed. You don't call the CDN, the CDN calls you.
    – Jack
    Oct 27, 2017 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.