nicolasazrak / caddy-cache

Caching middleware for caddy
Mozilla Public License 2.0
110 stars 30 forks source link

Support caching in memory? #21

Open nottrobin opened 6 years ago

nottrobin commented 6 years ago

Static content will not see great benefits.

Would it be possible to add an option to store the cache in memory instead of in disk? This could presumably improve performance so that you then would see performance improvements, even for static content.

nicolasazrak commented 6 years ago

I did it once, but after doing a simple benchmark, it didn't improve the performance a lot. It seems that the operating system keeps a lot of buffers in memory so when you read the same file it doesn't have to go to disk.

Creating a new storage shouldn't be that hard, there is an interface for it (https://github.com/nicolasazrak/caddy-cache/blob/master/storage/response_storage.go), but it has to be benchmarked to check it's working as expected and it performs as expected. PR are welcome 😄

nottrobin commented 6 years ago

Yep fair enough, I agree it should be benchmarked. I have never worked in go, so I don't see myself having time to work out how to submit a PR any time soon I'm afraid.

ahoeg commented 5 years ago

Instead of cache to disk just mount tmpfs to that path?

sillygod commented 4 years ago

Recently, I revise this repo to be consistent with the caddy 2's structure and support in_memory. In my experiment, caching in memory is actually more efficient. Anyone is interested can see this (https://github.com/sillygod/cdp-cache#test-result).