【发布时间】:2016-11-10 10:43:48
【问题描述】:
我使用 Eclipse 创建了一个示例 GWT+AppEngine 项目,并添加了一个 contact.gwt.xml 文件作为客户端。从contact.html 创建的对应*.contact.nocache.js 不会随着代码更改而更新。我在内部 Jetty 服务器上的 localhost 上运行它。
这是我的文件。
contact.html
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>contact</title>
<script type="text/javascript" laguage="javascript"
src="contact/org.restlet.example.firstapplication.contact.nocache.js?dummyTimeParam=<%=System.currentTimeMillis() %>"></script>
</head>
<body>
<h1>About a contact</h1>
<table>
<tr>
<th>Contact 102</th>
<th>Home address</th>
</tr>
<tr>
<td id="contactContainer" style="vertical-align: top"></td>
<td id="homeAddressContainer"></td>
</tr>
<tr>
<td id="buttonContainer" colspan="2"></td>
</tr>
</table>
</body>
</html>
contact.gwt.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.user.User" />
<inherits name="org.restlet.Restlet" />
<source path="client" />
<source path="shared" />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<entry-point class='org.restlet.example.firstapplication.client.ContactModule' />
<!-- allow Super Dev Mode -->
<add-linker name="xsiframe"/>
</module>
appengine.web.xml 的相关部分
<static-files>
<include path="**" />
<!-- The following line requires App Engine 1.3.2 SDK -->
<include path="**.nocache.*" expiration="0s" />
<include path="**.cache.*" expiration="365d" />
<exclude path="**.gwt.rpc" />
</static-files>
Restlet 应用模块
public class TestServerApplication extends Application {
@Override
public Restlet createInboundRoot() {
Router router = new Router(getContext());
Directory dir = new Directory(getContext(), "war:///");
router.attachDefault(dir);
router.attach("/contacts/123", ContactServerResource.class);
return router;
}
}
无论我在contact.html 文件中进行什么更改,它都会更新,但它对应的Java 文件的onModule() 永远不会被调用。它总是为 .nocache.js 文件获取 304 响应代码,该文件从“/war/contact/”位置获取相同的 .cache.html 文件。
我认为,我需要按照此处 (how to clear cache in gwt?) 的说明添加过滤器,但我不确定发生了什么以及如何在不使用 Java servlet 的情况下添加此过滤器。任何帮助,将不胜感激。
【问题讨论】:
-
您的
*.nocache.js似乎被缓存在浏览器中(或者可能在某些代理中)。尝试清除浏览器缓存并重新加载页面。如果它有效,那将确认缓存问题,您需要以某种方式强制 Web 服务器发送缓存标头。 -
感谢您的提示。这是我的一个错误。
标签: java http google-app-engine gwt restlet