nginx 设置css失效时间,缓存时间

发布于 / 随记 / 0条评论 / Tags: http / 4 次浏览

发现站点得css过其时间比较短,然后打开nginx看了下,如下代码

  location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

但是用chrome打开network,会发现:

Cache-Control: max-age=43200

Expires: Thu, 01 Nov 2018 12:59:27 GMT

cache control 会覆盖expires属性的,而且cache control受支持的浏览器较广,所以加入如下代码


add_header    Cache-Control  max-age=604800;

然后reload nginx配置


/usr/local/nginx/sbin/nginx -s reload 

    评论区(暂无评论)