富Internet应用程序中的客户端缓存

时间:2022-02-27 15:37:33

I'm starting to step into unfamiliar territory with regards to performance improvement and our RIA (Rich Internet Application) built with GWT. For those unfamiliar with GWT, essentially when deployed it's just pure JavaScript. We're interfacing with the server side using a REST-style XML web service via XMLHttpRequest.

我开始步入不熟悉的领域,关于性能改进和我们使用GWT构建的RIA(富互联网应用程序)。对于那些不熟悉GWT的人来说,基本上在部署时它只是纯粹的JavaScript。我们通过XMLHttpRequest使用REST风格的XML Web服务与服务器端连接。

Our XML is un-marshalled into JavaScript objects and used within the application to represent the data model behind the interface. When changes occur, the model is updated and marshalled back to XML and sent back to the server.

我们的XML被解组为JavaScript对象,并在应用程序中用于表示接口背后的数据模型。发生更改时,模型将更新并编组回XML并发送回服务器。

I've learned the number one rule of performance (in terms of user experience) is to make as few requests as possible. Obviously this brings up the possibility of caching. Caching is great for static data but things get tricky in a multi-user system where data on the server may be changing. Also, use of "Last-Modified" and "If-Modified-Since" requests don't quite do enough since we'd like to avoid unnecessary requests altogether.

我已经了解到性能的第一条规则(就用户体验而言)是尽可能少地提出请求。显然这会带来缓存的可能性。缓存非常适合静态数据,但在服务器上的数据可能正在发生变化的多用户系统中,事情变得棘手。此外,使用“Last-Modified”和“If-Modified-Since”请求还不够,因为我们希望完全避免不必要的请求。

I'm trying to figure out if caching data in the browser is even right for us before researching the approaches. I hope someone has tread this path before. I'm looking for similar approaches, lessons learned, things to avoid, etc.

我想在研究方法之前弄清楚浏览器中的缓存数据是否适合我们。我希望以前有人踏上这条道路。我正在寻找类似的方法,经验教训,要避免的事情等。

I'm happy to provide more specific info if needed...

如果需要,我很乐意提供更具体的信息......

1 个解决方案

#1


For GWT, if performance matters that much to you, you get better performance by sending all the data you need in a single request, instead of querying multiple small data. I would recommend against client-side data caching as there are lots of issues like keeping the data in sync with the database.

对于GWT,如果性能对您很重要,则可以通过在单个请求中发送所需的所有数据来获得更好的性能,而不是查询多个小数据。我建议不要使用客户端数据缓存,因为存在许多问题,比如保持数据与数据库同步。

Besides, you already have a good advantage with GWT over traditional html apps. Unless you are dealing with special data (eg: does not become stale too quickly - implies mostly-read queries) I found out that there is no special need for caching. You are better off doing a service-layer caching, since most of the time should come of server-side processing.

此外,与传统的html应用相比,你已经拥有GWT的优势。除非你正在处理特殊数据(例如:不会太快变得陈旧 - 意味着主要是读取查询),我发现没有特别需要缓存。你最好做一个服务层缓存,因为大部分时间都应该来自服务器端处理。

If you can provide more details about the nature of the app, maybe some different conclusions can be taken.

如果您可以提供有关应用程序性质的更多详细信息,则可能会得出一些不同的结论。

#1


For GWT, if performance matters that much to you, you get better performance by sending all the data you need in a single request, instead of querying multiple small data. I would recommend against client-side data caching as there are lots of issues like keeping the data in sync with the database.

对于GWT,如果性能对您很重要,则可以通过在单个请求中发送所需的所有数据来获得更好的性能,而不是查询多个小数据。我建议不要使用客户端数据缓存,因为存在许多问题,比如保持数据与数据库同步。

Besides, you already have a good advantage with GWT over traditional html apps. Unless you are dealing with special data (eg: does not become stale too quickly - implies mostly-read queries) I found out that there is no special need for caching. You are better off doing a service-layer caching, since most of the time should come of server-side processing.

此外,与传统的html应用相比,你已经拥有GWT的优势。除非你正在处理特殊数据(例如:不会太快变得陈旧 - 意味着主要是读取查询),我发现没有特别需要缓存。你最好做一个服务层缓存,因为大部分时间都应该来自服务器端处理。

If you can provide more details about the nature of the app, maybe some different conclusions can be taken.

如果您可以提供有关应用程序性质的更多详细信息,则可能会得出一些不同的结论。