部署代码后如何强制浏览器重新加载静态资产? [英] how to force browsers reload static assets after code deployment?

查看:108
本文介绍了部署代码后如何强制浏览器重新加载静态资产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行以下设置:haproxy->网络流量->清漆-> nginx(提供静态资产)-> node.js(动态内容)和haproxy-> websockets-> node.js

I'm running the following setup: haproxy -> web traffic -> varnish -> nginx (serve static assets) -> node.js (dynamic content) and haproxy -> websockets -> node.js

如何在代码部署后强制浏览器刷新静态资产(JavaScript,CSS等)? (要终止/清除缓存吗?)

How can I force browsers to refresh static assets (JavaScript, CSS, ..) after code deployment? (expire/purge the cache?)

推荐答案

您可以将带有版本号的查询字符串添加到文件中.修订版本号的增加将迫使所有资产重新回到浏览器中.

You can add a querystring to the file with a revision number. Increasing the revision number will force all the assets to come back down to the browser.

<script type="text/javascript" src="jquery.min.js?r=223"></script>

这篇关于部署代码后如何强制浏览器重新加载静态资产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆