Blogger Information
Blog 16
fans 0
comment 0
visits 14496
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
nginx expires缓存优化
进击的小菜鸟
Original
826 people have browsed it

nginx的缓存设置 提高网站性能

对于网站的图片,尤其是新闻站,图片一旦发布,改动的可能是非常小的

我们希望 能否在用户访问一次后 图片缓存在用户的浏览器端, 且时间比较长的缓存

这是就可以用到nginx的expires了  写在server段或者location段中

格式:  expires   xxx(s秒,m分,h小时,d天); 过期时间

另:304 也是一种很好的缓存手段

原理是:服务器响应文件内容时,同时想要etap标签(内容的签名,内容一变,他也变,)和

last_modified_since2个标签值

浏览器下次去请求时,头信息发送这两个标签,服务器 检测文件有没有发生变化,没有的话之间返回头信息etag,last_modified_since

浏览器知道内容没有改变,于是直接调用本地缓存.对于变化周期较短的,如静态html,js,css比较适用


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!