主机名别名对 Java applet 缓存有何影响?
我有两台主机名为 comp1
和 comp2
的服务器。我还有一个浮动别名 (master
),它动态映射到两台服务器之一。我从两台服务器提供相同的小程序。客户端通常连接到 master
,但完全允许直接连接到 comp1
或 comp2
。
客户抱怨他们总是不得不等待小程序加载(它很大)。我认为一旦客户端下载了必要的 jar,它们就会被缓存并且不会再次加载。起初我以为客户端的插件设置为不缓存,但我想我已经找到了问题的原因,虽然我不明白。
- 首次将客户端连接到
master
(当前指向comp1
)。必须等待 jar 下载。这是预料之中的。 - 再次将客户端连接到
master
。我不必等待罐子下载。这也是预期/期望的行为。 - 将客户端连接到
comp1
。必须等待 jar 下载。我不想发生这种情况,因为它是同一台服务器,但我可以理解为什么,因为comp1
在客户端看来是一个完全不同的主机。 - 将客户端连接回
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.
- Connect client to
master
(which is currently pointing tocomp1
) for the first time. Must wait for jars to download. This is expected. - Connect client to
master
again. I don't have to wait for the jars to download. This is also expected/desired behavior. - 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, ascomp1
appears to the client as a completely different host. - 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Avenus 进行调查:
这很可能是 jar 文件名的结果 - 例如,如果它总是下载到 %TMP%\app.jar,那么每次您访问 app.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: