zoukankan      html  css  js  c++  java
  • Nginx优化_定义对静态页面的缓存时间

    修改Nginx配置文件,定义对静态页面的缓存时间

    proxy ]# vim /usr/local/nginx/conf/nginx.conf

    server {

             listen 80;

             server_name localhost;

             location / {

                            root html;

                            index index.html index.htm;

                            }

             location ~* .(jpg|jpeg|gif|png|css|js|ico|xml)$ {

                                expires    30d;            //定义客户端缓存时间为30天

                                }

             }

    proxy ]# cp /usr/share/backgrounds/day.jpg   /usr/local/nginx/html  /拷贝一个jpg文件到网页目录

    proxy ]# /usr/local/nginx/sbin/nginx -s reload

    # firefox http://192.168.4.5/day.jpg      //优化后,使用Firefox浏览器访问图片,查看缓存信息

    结束.

  • 相关阅读:
    关于firstChild,firstElementChild和children
    trim(),正则表达式中文匹配
    Shell之基本用法
    Samba服务部署
    Linux基础(3)
    linux基础(2)
    Linux基础(1)
    网络基础及网络协议
    操作系统简介
    为何要学习计算机基础
  • 原文地址:https://www.cnblogs.com/liusingbon/p/11119348.html
Copyright © 2011-2022 走看看