开发者

Is it possible to set content expiration on the server (IIS) to force a new script file version to be downloaded?

Having released a new web application, updates are going out fairly frequently. Browsers cache external script and CSS files, and when updated, UI behaviour is not as it should be if the user's browser continues to use a cache version of the script file.

Is it possible to set the server to issue one time cache control headers so that any new requests pull new versions of all files referenced from a URL?

If not, any advice on how to deal with this effi开发者_开发百科ciently?


The ways rails does it is by appending a number to the end of the files as they are referenced. You can append a number to the end of the file, and make the number change with a new build

<script src="jquery.js?r=2301293123"/>


Adding a version number to the file name is the most efficient version of ensuring that all clients has the most recent version. The browser will see it as an all new file.

The browser will cache a resource based on HTTP caching headers. If it is told that a CSS file (for instance) is valid for a given time period, then it will not try to re-download it before that time has passed. This works on a resource level, so you cannot instruct the browser that a given resource has actually expired, until it tries to download it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜