Is there a standard practice for forcing users to refresh their cached browser content after intranet deployments? They tend to have conflicting JavaScript cached in their browse开发者_运维百科rs, and must hit F5 to get rid of JavaScript errors in IE 8.0. Per management, we deploy during business hours.
The need is to invalidate/expire each user's cache a single time on first hit to the site, then let the user resume caching normally.
Thanks!
You can't force a browser to flush its cache, but you can force it to reload something by adding a dummy query part to the URL:
<script src='js/stuff_that_changes.js?dummy=001'></script>
When you want to force a new version, you update the URL references to "002", "003", etc. Exactly how you do that depends a lot on your server-side technology.
Since you mention this is for an intranet application, one approach you can take to help in this type of situation is to alter the expiration of all items the browser might cache from the intranet site by setting the HTTP Response Headers for all intranet site content. If all users on the intranet are expected to have relatively speedy connections (i.e. are they all on the office LAN), then you can force the expiration to a very low value and it should not too problematic unless you have a very large number of users or have users with slower connections. This way all items in the user's browser cache are exiring relatively quickly and you shouldn't have much of an issue with rolling out frequent changes to the site. The following article is a howto on configuring this in IIS7.
http://technet.microsoft.com/en-us/library/cc770661%28WS.10%29.aspx
精彩评论