Reputation: 1937
I'm trying to implement the server-side cache in Node JS, I've read about express-redis-cache
, but how would this solution work with load balanced node servers? I might use something like AWS Redis Service, but it loses the whole purpose of using Redis on some external server as it increases latency. Can you suggest the best approach for this?
PS - I have some .md
& .json
files using which I generate the .html
files and return. So, instead of doing this, I want to have some caching which will store this generated .html
files. I'll update the cached content only when my .md
& .json
files are updated.
Upvotes: 1
Views: 2430
Reputation: 7742
I've read about express-redis-cache, but how would this solution work with load balanced node servers?
It wouldn't be a problem because all your load balanced node servers would connect to the same Redis host, which is fine.
I might use something like AWS Redis Service, but it loses the whole purpose of using Redis on some external server as it increases latency
It depends how you architect your app. If you are fully hosted on AWS, Elasticache is designed for this, latency would be minimal as connection will be within the VPC which is fast. If you need to connect to elasticache from a client on premise, you still have options: VPN (not ideal) or DirectConnect which would be much faster than a VPN.
Having said that, if you are looking to cache .html files probably then look at CloudFront instead of a bespoke caching solution using Redis.
Upvotes: 3