Skip to content
nginx
location / {
    # 强制缓存

    # expires 30s;   
    # expires 30m;  
    # expires 2h;     
    # expires 30d;   

    # node 和 nginx 默认的 http 版本都是 1.1。
    # nginx 中不要同时开启 expires 和 cache-control,否则 cache-control 会失效。
    # node 中响应头中设置 expires 会报错。
    add_header Cache-Control "max-age=300";

    # 协商缓存
    # last-modified 和 etag 是默认开启的
    # 响应头中会自动添加 If-Modified_Since 和 If-None-Match 字段

    # 关闭 etag
    # etag off;

    # 关闭 last-modified
    # 方法一
    # add_header Last-Modified "";
    # 方法二 
    # if_modified_since off;
    
    root html;
    index index.html;
}