Answer the question
In order to leave comments, you need to log in
How to calculate md5 from url path in Nginx without query args (needed for caching)?
The algorithm is as
follows: 1) we consider md5 or any other hash from /product/mp3501
2) we take the first 3 characters 5B3
3) we redirect the request to the directory with the 5B3 file already prepared by the backend /product/mp3501/index.html
PS
As I understand it, in one directory there are not it's worth trying to create ~700000 subdirectories in the first nesting level, so I'm trying to make several levels of nesting.
There is another option instead of the file system in redis to put pages and read them with nginx (ready for criticism)
Answer the question
In order to leave comments, you need to log in
https://github.com/openresty/lua-nginx-module/blob...
nginx.org/en/docs/njs/reference.html#crypto
In 99%, some of this already exists or is easily added.
And why not use the regular nginx caching, which pulls the back once and neatly decomposes the cache as it should and monitors its state?
Or in your case, the back is engaged in generating statics, you arrange the files into directories in advance and want nginx to "smartly" pull them?
In this case, I would write the simplest router in any programming language, in which I would read the md5 cache, read the necessary file from the disk and give it to nginx, and nginx, in turn, would cache this response and store the cache.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question