location / {
    if_modified_since off;
    #禁用缓存,不需要304缓存比对
    }

    location ~* \.(gif|jpe?g|png|ico|swf)$ {
      expires 168h;
      add_header Pragma public;
      add_header Cache-Control "public,must-revalidate,proxy-revalidate";
    }
    location ~* \.(css|js)$ {
      expires 10m;
      add_header Pragma public;
      add_header Cache-Control "public,must-revalidate,proxy-revalidate";
    }
    ...

也可以:

location /test/ {
                  root   /home;
                 #index  index.html index.htm
                  try_files $uri /h5/index.html;
                  if ($request_filename ~* .*\.(?:htm|html)$)
                  {
                    add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
                  }
                 if ($request_filename ~* .*\.(?:js|css)$)
                 {
                   expires      7d;
                 }
                if ($request_filename ~* .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$)
                {
                  expires      7d;
                }
              }

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code