Nginx(expires 缓存减轻服务端压力)

1. expires 是在http的回应中,也就是Response-Header,expires [time| epoch| max| pff] ,后面的设置会影响Cache-Controller, 如果是负数则 on-cache,否则就是max-age=time;

2. 

expires 30s; //表示把数据缓存30秒

expires 30m;//表示把数据缓存30分

expires 10h;//表示把数据缓存10小时

expires 1d;//表示把数据缓存1天

3. expires一般的都是放在http,server,location里面的,比如你设置当前目录下的图片缓存到浏览器:

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${

    root /home/wwwroot/default;

    expires 30d;

  }

这样,你一访问图片(127.0.0.1\Jackey.png),就会自动的缓存到浏览器的了。

猜你喜欢

转载自www.cnblogs.com/Jackey-fighting/p/9144010.html