主机名别名对 Java applet 缓存有何影响?

发布于 2024-11-04 04:44:35 字数 940 浏览 1 评论 0原文

我有两台主机名为 comp1comp2 的服务器。我还有一个浮动别名 (master),它动态映射到两台服务器之一。我从两台服务器提供相同的小程序。客户端通常连接到 master,但完全允许直接连接到 comp1comp2

客户抱怨他们总是不得不等待小程序加载(它很大)。我认为一旦客户端下载了必要的 jar,它们就会被缓存并且不会再次加载。起初我以为客户端的插件设置为不缓存,但我想我已经找到了问题的原因,虽然我不明白。

  1. 首次将客户端连接到 master(当前指向 comp1)。必须等待 jar 下载。这是预料之中的。
  2. 再次将客户端连接到master。我不必等待罐子下载。这也是预期/期望的行为。
  3. 将客户端连接到 comp1。必须等待 jar 下载。我不想发生这种情况,因为它是同一台服务器,但我可以理解为什么,因为 comp1 在客户端看来是一个完全不同的主机。
  4. 将客户端连接回master。同样,我必须等待所有 jars 下载完毕。 这不是我所期望的。 jar 应该已经在步骤 1/2 中下载。

使用 Java 控制面板,我可以看到缓存中的资源。在我看来,资源是通过 URL 键入的,所以我不知道为什么我会得到我所做的事情。似乎同一服务器的两个不同主机名正在搞乱客户端的缓存。

我应该提到的是,master 主机名不仅仅是一个 DNS 别名。它是应用程序运行时 comp1/comp2 动态绑定/取消绑定的实际不同 IP 地址。

您能解释一下我在这里看到的情况,或者建议一些调查途径吗?

I have two servers with hostnames comp1 and comp2. I also have a floating alias (master) that is dynamically mapped to one of the two servers. I am serving the same identical applet from both servers. Clients normally connect to the master one, but it is perfectly allowable to connect to either comp1 or comp2 directly.

Clients are complaining that they are always having to wait for the applet to load (it is quite large). I thought that once the client downloaded the necessary jars, they would be cached and wouldn't be loaded again. At first I thought the client's plugin was set to not cache, but I think I've found the cause of the problem, although I don't understand it.

  1. Connect client to master (which is currently pointing to comp1) for the first time. Must wait for jars to download. This is expected.
  2. Connect client to master again. I don't have to wait for the jars to download. This is also expected/desired behavior.
  3. Connect client to comp1. Must wait for jars to download. I'd rather not have this happen, since it is the same server, but I can understand why, as comp1 appears to the client as a completely different host.
  4. Connect client back to master. Again, I must wait for all the jars to download. This is not what I expected. The jars should have been downloaded already in steps 1/2.

Using the Java control panel, I can see the resources that are in the cache. It appears to me that the resources are keyed by URL, so I don't know why I'm getting what I do. It seems as though that the two different hostnames for the same server is messing up the client's cache.

I should mention that the master hostname isn't just a DNS alias. It is an actual different IP addrress that comp1/comp2 dynamically bind/unbind to while the application is running.

Can you explain what I am seeing here, or suggest some avenues to investigate?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风吹短裙飘 2024-11-11 04:44:35

Avenus 进行调查

这很可能是 jar 文件名的结果 - 例如,如果它总是下载到 %TMP%\app.jar,那么每次您访问 app.jar 时都会被踩踏。服务器。

可能的解决方法:

  • 为服务器上的文件设置别名,以便可以将其作为 master.jar、compN.jar 获取。
  • 使用 301 或 302 来提示浏览器只使用一个源 jar(您可以由于同源策略,需要对 jar 进行签名)

Avenus to investigate:

This may well be a consequence of the jar filename - e.g. if it is always downloaded into %TMP%\app.jar, then app.jar will get stomped on each time you visit a server.

Possible workarounds:

  • Alias the file on the servers, so it can be fetched as master.jar, compN.jar
  • Use a 301 or 302 to hint to the browser than only one source jar is used (you may need to sign the jar due to same-origin policies)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文