nginx(4、缓存)

nginx提供内置的缓存功能,对静态文件,如html\css\js等能够缓存在本地,即nginx服务器的某个目录下。

其配置主要是两部分:

1、在http下配置一个缓存路径:

proxy_cache_path /nginx-1.7.9/cache levels=1:2 keys_zone=CACHE:20m inactive=1d max_size=100;

2、在server里使用该缓存:

   server {
        listen       800;
        server_name  localhost;        
        location / {
            proxy_cache CACHE; //所用的cache,即keys_zone
            proxy_cache_key $host$uri$is_args$args;//缓存关键字
            proxy_cache_valid any 1d; //所有状态的http请求缓存一天
            proxy_pass  http://fredric.net;
        }

备注:在windows下无法使用nginx缓存,至少我用的1.7.9 貌似不能用。

 

posted @ 2015-05-22 16:25  Fredric_2013  阅读(199)  评论(0编辑  收藏  举报