下次登录时如何清除客户端缓存 [英] how to clear my clients cache next time they log in

查看:150
本文介绍了下次登录时如何清除客户端缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在hostgator上运行了一个应用程序。当我对js文件进行更改时,我的用户只有在清除缓存后才能看到更改。这是将更改推送到我的应用程序的唯一选择吗?基本上,我应该进行更改,更新文件,然后请求所有用户清除其缓存?

I have an application running on hostgator. When I make changes to the js files my users don't see the changes until they clear their cache. Is this the only option to push changes to my application? Basically, I'm supposed to make the change, update the files and then request all users to clear their cache?

推荐答案

您需要对文件包括使用版本控制。每当您更改文件包含的URI时,浏览器都不会找到缓存匹配项,并将重新下载该包含。

You need to use versioning on your file includes. Anytime you change the URI of your file includes, the browser won't find a cache match and will re-download the include.

例如:

<script type="text/javascript" src="include/232/init.js"></script>

其中232是您的可修改版本号,每次发布新代码时都应更改。

Where 232 is your modifiable version number that should be changed whenever you release new code.

或者,您可以使用查询字符串:

Alternatively, you can use query strings:

<script type="text/javascript" src="include/init.js?232"></script>

重点是,每当您希望访问者重新访问时,都应以某种方式更改文件包含URI -下载文件。

The point is that you should change the file include URI in some manner whenever you want your visitors to re-download the file.

如果您使用PHP或其他服务器端语言,则可以将此版本设置为在修改文件包括时自动进行:http://derek.io/blog/2009/auto-versioning-javascript-and-css-files /

If you use PHP or another server-side language, you can setup this versioning to occur automatically whenever your file includes are modified: http://derek.io/blog/2009/auto-versioning-javascript-and-css-files/

这篇关于下次登录时如何清除客户端缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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