检索文档列表时的 Web 缓存
我们需要利用客户端资源来获取包含任务的列表。
客户端需要:
- 收到列表更新的通知
- 能够重新排序/过滤列表(向服务器请求更新,其中包含客户端不知道/缓存中的任务)
问题出现在初始加载或大型列表更新(从“分配给我的任务”更改为“有关 x 的任务”)
最快的做法是将所有任务放回到列表中,而不是单独的(10 个以上)请求。
但是,当我请求更新列表中的任务时,电子标签将无济于事,因为它不是单独下载的。
有没有某种方法可以让浏览器根据其各自的网址缓存列表中的项目?
或者一种创建 JavaScript 缓存的方法,该缓存可以在导航结束后继续存在?
- 如果我离开并转到任务 URL,我的 js 对象会保留下来吗? 我怀疑没有。
- 如果我离开,然后返回,我的 javascript 对象会保留下来吗? 我怀疑是的。
- 如果是这样,是否可以有一个“任务列表加载”页面来检查历史记录并返回到现有的任务列表? 我认为不会——安全。
我想我只需要接受初始加载点击并单独检索任务,以便以后的请求很快(并减轻服务器的负载)。
We have a need to leverage client side resources for lists containing tasks.
The client needs to:
- be notified of updates to the list
- be able to re-order/filter the list (requesting an update from the server with tasks that the client does not know of/have in cache)
The problem comes on initial load or large list updates (changing from "tasks assigned to me" to "tasks regarding x")
The fastest thing to do is get all the tasks back in a list, instead of individual (10+) requests.
But E-tags will not help when I request an update to a task in the list, as it was not downloaded individually.
Is there some way of getting the browser to cache items in a list against their individual urls?
Or a way of creating a javascript cache that will survive a navigation away?
- If I navigate away, and go to the task url, will my js objects survive? I suspect no.
- If I navigate away, then hit back, will my javascript objects survive? I suspect yes.
- If so, is it possible to have a "task list load" page that will inspect the history and go back to the existing task list? I think no - security.
I'm thinking I'll just have to take the initial loading hits and individually retrieve tasks, so that later requests are fast (and take the load off the server).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 HTML5 中,有 Window.sessionStorage 属性可以存储内容针对选项卡/窗口中的特定会话(即使针对同一会话运行,其他窗口也将拥有自己的存储)。
规范中还提供了 localStorage 和数据库存储选项。
In HTML5, there is the Window.sessionStorage attribute that is able to store content against a specific session within a tab/window (other windows will have their own storage, even when running against the same session).
There is also localStorage, and database Storage options available in the spec as well.
HTML5 距离实施还有一段距离,但您或许可以使用 Google Gears 作为本地存储需要。
另外,我不知道我们正在讨论有多少并发客户端和任务,任务有多大,以及这样的请求可能会给数据库带来多大的压力,但我认为您应该能够顺利运行而无需任何操作缓存,10+个请求看起来并不算多。 如果流量不是瓶颈,我会在服务器上放置缓存并保持客户端“愚蠢”。
HTML5 is still a bit far away from being implemented, but you might be able to use Google Gears for your local storage needs.
Also, I've no idea how many simultaneous clients and tasks we're talking about, how big the tasks are and what strain such a request might put on the database, but I'd think you should be able to run smooth without any caching, 10+ requests doesn't seem that much. If traffic is not the bottleneck, I would put caching on the server and keep the client 'dumb'.