The script that we currently use to clear the nginx cache is taken from [login to view URL] And it's very slow; it make take more than an hour. We've found out that in nginx cache, the 2nd or 3rd line of each file in the cache folder contains a text-reference to the original file name and path; and so we thought we could use "grep" to make script that performs better. This is what we came up with:
find /var/cache/nginx -type f -print0 | xargs -0 grep -lZ "12345678" < <(head -n 5 $1) | xargs -0 rm
In that line the "12345678" is a part of the original request URL. Here is a sample of what is it looks like when I do "head -n 5 /var/cache/nginx/2/34/a773fbbc414d97a4b59719c93b060222" (that's one of the cache files)
KEY: /vod/12345678/[login to view URL]
HTTP/1.1 200 OK
Date: Wed, 07 Nov 2018 10:42:58 GMT
It works, but it's still relatively slow (around 30 minutes if there's a lot in cache). Do you think it's possible to make this fast(er)?
4 фрилансеров(-а) в среднем готовы выполнить эту работу за $164
Good day. Can help You with further speed otimization of this sample nginx shell cache purge script. Think can manage more quick result in the end. Tnx and Regards.
Hi, I have read your exact requirements and checked the script you are using. I understood the issue and will fix it as per your guidance. I have +7 years of experience as a Linux Administrator. Regards Karuna