Answer the question
In order to leave comments, you need to log in
How to reset the cache on all servers?
There is nginx as a proxy for 2 backends. Each backend has its own file cache. When adding news to the site, you need to reset the cache on all servers. Backends do not communicate with each other, but in general it can be done.
Here is the diagram: here
What are the strategies for flushing the cache?
While I came up with this option: add a method to the api / api / cache / clear, write a code on nginx to send a get request and a request was made to all servers. And when the news is added, call this method. How to write such code for nginx or another solution?
Answer the question
In order to leave comments, you need to log in
Yes, you can send a request, but:
1) There is a functionality for clearing the cache according to certain criteria, it is available only in the commercial version of nignx
https://nginx.org/en/docs/http/ngx_http_proxy_modu...
2) Of course, you can cheat, so that files are deleted on a specific request. But it's better to protect it somehow (at least basic auth). And it seems that this will require a restart of nginx (maybe reload will suffice).
3) There is also a module https://github.com/FRiCKLE/ngx_cache_purge - but I don't know how it
works now. Alternatively, move the cache from nginx to another more manageable storage (for example, radish) and clear it when editing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question