您好,登录后才能下订单哦!
密码登录
            
            
            
            
        登录注册
            
            
            
        点击 登录注册 即表示同意《亿速云用户服务条款》
        当Nginx将网页数据返回给客户端后,可设置缓存的时间,以方便在日后进行相同内容的请求时直接返回,避免重复请求,加快了访问速度。一般针对静态网页设置,对动态网页不设置缓存时间。可在Windows客户端中使用fiddler查看网页缓存时间。
可修改配置文件,在http段、或者server段、 或者location段加入对特定内容的过期参数
[root@localhost nginx-1.12.2]# cd /mnt/tools/
[root@localhost tools]# ls
awstats-7.6.tar.gz                fiddler.exe                jdk-8u191-windows-x64.zip  LNMP         zhuang.mp4
cronolog-1.6.2-14.el7.x86_64.rpm  forbid.png                 john-1.8.0.tar.gz          picture.jpg
extundelete-0.2.4.tar.bz2         intellijideahahau2018.rar  LAMP-C7                    yuan.mp4
[root@localhost tools]# cp picture.jpg /usr/local/nginx/html/    //复制图片
[root@localhost tools]# cd /usr/local/nginx/html/
[root@localhost html]# ls
50x.html  index.html  picture.jpg
[root@localhost html]# 
[root@localhost html]# vim index.html
<h2>Welcome to nginx!</h2>
<img src="picture.jpg"/>   //添加
[root@localhost html]# systemctl stop firewalld.service    //关闭防火墙
[root@localhost html]# setenforce 0   //关闭增强性安全功能
[root@localhost html]# 


[root@localhost html]# vim /usr/local/nginx/conf/nginx.conf
        location ~ \.(gif|jepg|jpg|ico|bmp|png)$ {   //添加缓存
            root html;   //站点
            expires 1d;   //缓存一天
        }
[root@localhost html]# service nginx restart    //重启服务
[root@localhost html]#


免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。