Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What are advantages of redis cache over nginx cache? #313

Open
DeeKey opened this issue Dec 12, 2023 · 2 comments
Open

What are advantages of redis cache over nginx cache? #313

DeeKey opened this issue Dec 12, 2023 · 2 comments

Comments

@DeeKey
Copy link

DeeKey commented Dec 12, 2023

I am using nginx cache with module ngx_cache_purge.
Does redis cache (with nginx with module srcache) has advantages over the nginx cache?
What are they?

@DeeKey DeeKey changed the title What are advances of srcache over nginx cache? What are advantages of redis cache over nginx cache? Dec 12, 2023
@gagan0123
Copy link
Member

@DeeKey

There are several advantages of using Redis cache over the default NGINX cache:

  1. Redis, being in memory cache, can serve requests faster (though we can mount NGINX cache in TMPFS which stays in RAM)
  2. Redis offers various eviction policies, letting you control how and when data is removed from the cache. This is more flexible compared to NGINX's caching mechanism.
  3. If you are building a distributed system, a single Redis instance can serve multiple NGINX instances running on different servers (similar thing can be achieved by having an NFS mount of the NGINX cache directory, but not that efficient)
  4. In Redis cache, you can purge pattern-based URLs all at once in a single request, e.g. https://example.com/category/* but the same is not possible in NGINX cache (as I remember) and you have to either send multiple requests to clear all cached pages matching that pattern individually, or clear the entire cache.

I hope this answers your question

@DeeKey
Copy link
Author

DeeKey commented Dec 14, 2023

In my setup NGINX cache is in TMPFS (/dev/shm). But the biggest problem with this setup is slow delete of cache during post editing.
Thus I hope that pattern based purging might help me to speed up the purging process!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants