0

Apparently, express-static and buffet cache only static files in the server memory. Is there a middleware which will allow me to cache AJAX results in the server memory? I need this to be done because I am storing my images in MongoDB. Does the Varnish reverse proxy cache AJAX results?

Chong Lip Phang
  • 8,755
  • 5
  • 65
  • 100
  • 1
    There are solutions available . one would be redis cache . There could be simpler solution like memory-cache npm module – Tanmay Patil Apr 07 '18 at 08:15
  • It's not overly hard to implement a simple cache yourself, either. For example: https://medium.com/the-node-js-collection/simple-server-side-cache-for-express-js-with-node-js-45ff296ca0f0 – Tomalak Apr 07 '18 at 09:35
  • Hmm... I am thinking perhaps the cached data can be gzipped and shared across threads. Moreover, there is a memory limit in node.js which prevents too much data to be cached... – Chong Lip Phang Apr 07 '18 at 09:41
  • Caching to disk is always an option, it will still be faster than re-calculating the response from scratch. – Tomalak Apr 07 '18 at 09:48
  • I think disk access is really slow, perhaps thousands of times slower than memory access and the computation involved. I am also wondering whether the default MongoDB WiredTiger engine cache is efficient enough alone. – Chong Lip Phang Apr 07 '18 at 09:54
  • If stuff is so cacheable, why don't you let clients cache it? – Tomalak Apr 07 '18 at 12:27

0 Answers0