配置nginx清除客服端缓存

如何配置nginx清除客服端缓存

清除客服端缓存
缓存策略:no-store表示不允许缓存,no-cache表示不允许缓存,must-revalidate表示必须重新验证,max-age=0表示缓存过期时间为0;设置响应头中的Pragma字段,表示不允许缓存;
过期时间:-1表示立即过期

  location /index.html {
        add_header Last-Modified $date_gmt; 
	    add_header Cache-Control no-store,no-cache,must-revalidate,max-age=0;   
	    add_header Pragma no-cache; 
        add_header Cache-Control no-cache,private;
         expires -1;
    }

Cache-Control 与Pragma 区别:
1、Cache-Control 是 HTTP/1.1 才有的,Pragma 是 HTTP/1.0 的。
2、Cache-Control 是强制缓存的指令,Pragma 是用来对 Cache 进行指令的,但它并不强制缓存。
3、Cache-Control 指令更加全面,比如支持更多的指令,支持更多的参数等,而 Pragma 仅仅支持一个 no-cache 参数,用来取消缓存

猜你喜欢

转载自blog.csdn.net/var_deng/article/details/128902273