我使用GWT编写了应用程序。它非常适合客户。但是,当我在应用程序中更改某些内容时,重新编译然后部署到服务器和客户端访问我的应用程序时,他的浏览器没有选择新版本的应用程序,而是使用以前的缓存版本。这会触发RPC错误和其他问题。
如何强制客户端浏览器在访问我的页面时获取应用程序的新版本,并使用缓存版本是与服务器上的匹配版本。
解决方案确保您的* .nocache。* 文件和您的起始页面(通常是index.html)都提供了正确的HTTP缓存标头。请参阅适用于不同类型资源的理想HTTP缓存控制标头讨论这个(有些困难)的话题。基本上,你可能要设置
Cache-Control:no-cache这些文件。 (顺便说一句,这只会在文件更改时强制重新下载 !)
如何做这个配置取决于您的Web服务器(对于Apache Httpd,您可以使用本指南 )。另外 - 如果您使用JavaEE服务器(Tomcat,Jetty,...)来提供这些文件 - 您可以使用Servlet过滤器。也许你想使用我的例子如何在Apache Tomcat的单个JS文件上设置Expires HTTP标头?
I have written application using GWT. It works perfectly for the client. But when I'm changing something in my application, recompiling and then deploying to the server and client access my application his browser is not picking up the new version of the application but uses previously cached version of it. This triggers RPC errors and other problems.
How can I force client's browser to get a new version of the application when they are visiting my page and use the cached version if it is matches version on the server.
解决方案Make sure, that your "*.nocache.*" files and your start page (usually "index.html") are served with the correct HTTP caching headers. See Ideal HTTP cache control headers for different types of resources for a discussion on this (somewhat difficult) topic. Basically, you'll probably want to set
Cache-Control: no-cachefor these files. (By the way, this forces a re-download only when the file has changed!)
How to do this configuration, depends on your web server (for Apache Httpd, you can use this guide).
Alternatively - if you use a JavaEE server (Tomcat, Jetty, ...) to serve these files - you can use a Servlet Filter. Maybe you'd like to use my example from How to set Expires HTTP header on a single JS file in Apache Tomcat?
更多推荐
在客户端刷新GWT应用程序
发布评论