zoukankan      html  css  js  c++  java
  • Nginx详解十一:Nginx场景实践篇之Nginx缓存

    浏览器缓存:

    HTTP协议定义的缓存机制(如:Expires、Cache-control等)

    当浏览器第一次请求的时候,浏览器是没有缓存的

    第二次请求开始就有缓存了

     

    校验过期机制

     配置语法-expires:添加Cache-Control、Expires头

    配置语法:expires [modifid] time;
    expires epoch | max | off;
    默认状态:expires off;
    配置方法:http、server、location、if in location

    先在/opt/app/code传几个html文件

     

    在配置文件中,新增一个关于html缓存的location配置

    location ~ .*.(htm|html)$ {
    #expires 24h; # 设置缓存24小时过期
    root /opt/app/code;
    }

     检查配置语法,并重载nginx

    nginx -tc /etc/nginx/nginx.conf
    nginx -s reload -c /etc/nginx/nginx.conf

    先清除缓存再访问

     再次刷新浏览器,访问状态就会变成304

    在配置文件中,把注释打开

     检查语法,重载

    再次请求

  • 相关阅读:
    单调栈
    单调队列
    线段树
    树状数组
    KMP模式匹配
    二分图最大匹配
    celery发送短信接口
    celery配置与基本使用
    celery介绍
    短信验证接口
  • 原文地址:https://www.cnblogs.com/zhongyehai/p/10507250.html
Copyright © 2011-2022 走看看