Website needs force refresh after deploy

2019-03-14 09:02发布

After deploying a new version of a website the browser loads everything from its cache from the old webpage until a force refresh is done. Images are old, cookies are old, and some AJAX parts are not working.

How should I proceed to serve the users with the latest version of the page after deploy?

The webpage is an ASP.Net webpage using IIS7+.

3条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-03-14 09:43

For ASP.NET you can use the cache control and expires headers. You can also set up similar headers in IIS 7 for your images. If you have any other cookies you can expire them manually.

I have not tried it, but it looks like you can do an ever better job of bulk setting cache control in IIS 7. See this thread and this link. At that point you are only left with unsetting any custom cookies you have (which you won't be able to control with HTTP cache control settings).

I don't know of any method to "unset everything all at once" easily.

查看更多
我只想做你的唯一
3楼-- · 2019-03-14 09:51

You can append a variable to the end of each of your resources that changes with each deploy. For example you can name your stylesheets:

styles.css?id=1

with the id changing each time.

This will force the browser to download the new version as it cannot find it in its cache.

查看更多
神经病院院长
4楼-- · 2019-03-14 09:53

You could use http headers to control the cache of your clients.

I'll just leave this here for you. http://support.microsoft.com/kb/234067

查看更多
登录 后发表回答