Home > Backend Development > PHP Tutorial > nginx as image browsing front-end cache configuration example

nginx as image browsing front-end cache configuration example

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-08 09:28:08
Original
1120 people have browsed it
#图片浏览cache
proxy_cache_path /var/cache/nginx/imgCache levels=2:2:2 keys_zone=imgCache:256m inactive=7d max_size=0m;
server
{
    listen 80;
    server_name img.xxxx.net;
    root /data/www/;

    location ~ \.(jpg|jpeg|jp2|png|gif|bmp|ico|wbmp|xbm|tiff)(/\d*)?(/\d*)?(\?.*)?$ {
        proxy_pass  http://127.0.0.1:8118;
        proxy_cache imgCache;
        proxy_cache_key $host$uri;
        proxy_set_header host inner.img.xxxx.com;
        proxy_cache_valid  200 30d;
        proxy_cache_valid any 1m;
        expires 30d;
    }

    access_log  /var/log/nginx/img_cache.log main;
    error_log   /var/log/nginx/img_cache.log.err debug;
}
server
{
    listen 8118;
    server_name inner.img.xxxx.net;
    root /data/www/;

    location ~ \.(jpg|jpeg|jp2|png|gif|bmp|ico|wbmp|xbm|tiff)(/\d*)?(/\d*)?(\?.*)?$ {
        fastcgi_pass  unix:/var/run/php-cgi.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        rewrite ^/(.*)$ /app/image/index.php?mod=download break;
        expires 7d;
    }

    access_log  /var/log/nginx/img_download.log main;
    error_log   /var/log/nginx/img_download.log.err debug;
}
Copy after login

The above introduces nginx as an image browsing front-end cache configuration example, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
nginx does not generate cache files
From 1970-01-01 08:00:00
0
0
0
Create different keys for query cache in Laravel
From 1970-01-01 08:00:00
0
0
0
Clear nginx file cache
From 1970-01-01 08:00:00
0
0
0
How to refresh cache in Laravel?
From 1970-01-01 08:00:00
0
0
0
How to set up cache in nginx settings
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template