在客户端刷新GWT应用程序

编程入门 行业动态 更新时间:2024-10-09 09:14:02
本文介绍了在客户端刷新GWT应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用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-cache

for 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应用程序

本文发布于:2023-11-16 14:44:51,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   客户端   GWT

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!