eye_mew
eye_mew

Reputation: 9133

Express JS: serving files out of memory vs serving static files

Is it worth my while to hold images(for example) in memory, as opposed to serving them out of static assets?

Will frequently requested static assets remain in memory?

Can anyone give me a sense of the performance impact?

Upvotes: 1

Views: 662

Answers (1)

Madara's Ghost
Madara's Ghost

Reputation: 174957

Unless you're serving users in the several thousands per second, I doubt it'll have that much of an impact since the bottleneck is bound to be network latency and transfer times anyway.

Regardless, you should utilize client-side cache in your favor, and make sure that the image isn't requested from the server each time.

Frequently requested images are not kept in memory by default as far as I know, you need to write your own application level code to do that.

The best advice I can give you is to try both and see what works for you. Your conditions and circumstances are unique to you, and no benchmark can give you an accurate representation of whether it's worth the extra memory usage or not.

Upvotes: 3

Related Questions