【问题标题】:*.nocache.js is not reloading the latest code changes (using Restlet and GWT)*.nocache.js 不会重新加载最新的代码更改(使用 Restlet 和 GWT)
【发布时间】: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


【解决方案1】:

我不知道我现在是否可以删除这个问题。但这是我的一个愚蠢的错误。我从另一个项目中复制了代码并将包名更改为“org.example.contact”。为以前的包创建的/war/&lt;oldPackageName&gt;/*.nocache.js 仍然存在,并且在 HTML 文件中被链接。当我用新包重新编译代码时,它创建了一个新的/war/&lt;newPackageName&gt;/*.nocache.js 文件,但 HTML 仍然指的是旧文件。一旦我弄清楚了编译过程,它就得到了修复。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 2011-05-26
    • 1970-01-01
    • 1970-01-01
    • 2013-10-27
    相关资源
    最近更新 更多