Last Thursday we just released a new version of our website. The big change was we converted from Prototype to jQuery. This of course included lots of changes to referenced javascript files. There were new css file changes as well. Unfortunately, many of our customers aren't seeing the changes. I even had one customer clear their browser cache, press F5 and download the js file directly. He still was getting the old version.
What methods do we have to notify all of the participants (browser, proxy servers, etc) of the changes to our files?
BTW, many of our customers are Fortune 500 companies. They use IE 6 开发者_Python百科and often are behind a proxy server.
We use Tomcat 6 and Apache 2.
I noticed that StackOverflow uses version numbers on their files
http://sstatic.net/so/js/question.js?v=5207
So I tried this on our site and it seems to be working. The one user who had an especially stubborn browser saw the results immediately after the change.
The thing I like about this is that it's really not that difficult for us to implement and it still allows the browsers and proxies to cache the files that don't change a lot.
For Tomcat, when you deploy make sure you delete everything in the work/Catalina/localhost directory prior to restarting. This is a cache directory for tomcat. Also adding the headers in your servlet/JSP as stated by me_here can be helpful.
If the proxy servers are caching your site, there's very little you can do. You can try adding CACHE-CONTROL and PRAGMA:NO-CACHE headers to your pages.
You should also try replicating the problem with as little between you and the server as possible. I've had problems with Tomcat holding onto files in its 'work' cache, so be sure to delete that.
I had a similar problem. In the end I "solved" it by sending http headers with every page to say the content had expired and force a renewal of the page. Not a very elegant solution though.
In PHP this was:
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
Not sure about Tomcat though.
精彩评论