Answer the question
In order to leave comments, you need to log in
Image caching
Hello. Please help me to implement this task:
There is this: You
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js)$ {
expires 4w;
root /var/www/public_html;
}
need to add a cache to it.
proxy_intercept_errors on;
proxy_cache STATIC;
proxy_cache_min_uses 5;
proxy_cache_valid 1d;
proxy_ignore_client_abort on;
proxy_temp_path /tmp;
proxy_cache_use_stale updating;
When requesting a picture, he searched in the cache folder, and if not there, he gave it with “root /var/www/public_html”.
Answer the question
In order to leave comments, you need to log in
It's a pretty common practice, I've done it too. However, I was told that modern fs effectively cache frequently requested files, besides, when changing the original, you do not have to smoke a copy from the cache.
If you don't have OpenVZ, don't worry and let fs do its job.
The cache is not needed here. At all. Or explain why you need it (what you want to achieve with this).
## Serve static
## root укажите, если надо
## такая регулярка лучше
location ~* \.(?:js|css|png|jpe?g|gif|ico|htc)$ {
expires max;
access_log off;
log_not_found off;
}
And another question. Who faced, tell me how best to implement.
Let's say there is another server with the same config:
location ~* \.(?:js|css|png|jpe?g|gif|ico|htc)$
Which takes pictures from the folder and distributes them, but if it is not there, it returns from the first server and puts it in this folder (but under a normal name, not md5)
Interested in the possibility of implementation only using Nginx, without rsync or other scripts.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question