典型的基于浏览器的Web解决方案可以使用缓存

时间:2021-07-07 03:52:39

Given a typical web application that may be implemented in a "server side" language, such as the ASP.NET collection or PHP, with a browser providing the end-user interaction is it possible to make use of a persistent local cache?

鉴于可以用“服务器端”语言(例如ASP.NET集合或PHP)实现的典型Web应用程序,使用提供最终用户交互的浏览器,是否可以使用持久性本地缓存?

For instance, take a simple centralised database storing thousands of staff records. It would be more efficient for the browser to have a local copy of the appropriate data as long as this cache doesn't become stale. How would this be accomplished? As far as I'm aware cookies are the extend of exposed browser memory and strict domain policy stops any interaction with the hard drive.

例如,采用一个存储数千个员工记录的简单集中式数据库。只要此缓存不会变得陈旧,浏览器就可以更有效地获得适当数据的本地副本。这将如何实现?据我所知,cookie是暴露浏览器内存的扩展,严格的域策略会阻止与硬盘的任何交互。

I'm thinking from a PHP or ASPX web form application (hypertext application?) perspective which I understand as stateless so I'm having difficulty understanding how this would be achieved. Would other .NET solutions offer any advantage, like .NET MVC or WCF?

我正在考虑从PHP或ASPX Web表单应用程序(超文本应用程序?)的角度来看,我理解为无状态,所以我很难理解如何实现这一点。其他.NET解决方案是否会提供.NET MVC或WCF等优势?

I should make a note that this is not considering the applet technologies Java, Flash, Silverlight et al.

我应该注意,这不是考虑applet技术Java,Flash,Silverlight等。

1 个解决方案

#1


4  

HTML5 localStorage and sessionStorage can house up to 5 MB or more depending on the browser for a domain.

HTML5 localStorage和sessionStorage最多可容纳5 MB或更多,具体取决于域的浏览器。

HTML5 ApplicationCache in particular is good for what you want as you can specify a manifest that is checked for modifications each request but only that file is accessed every time while your cached resources will not be requested unless directed to do so, saving tons of bandwidth. If you served the manifest file via server-side dynamic programming, you could easily implement a caching strategy by simply changing the manifest file timestamp or comment within the doc as you get new data in. The manifest file could be dynamically served based on a user's cookie so you could in affect have sets of data that you have per user if you needed to compartmentalize the data.

特别是HTML5 ApplicationCache适用于您想要的内容,因为您可以指定每个请求检查修改的清单,但每次访问时都只访问该文件,除非有指示这样做,否则会节省大量带宽。如果您通过服务器端动态编程提供清单文件,则只需在获取新数据时更改清单文件时间戳或文档内的注释即可轻松实现缓存策略。清单文件可以根据用户的动态提供如果您需要划分数据,那么您可能会影响每个用户拥有的数据集。

You would have to develop heavy on the JavaScript client-side with JSON.stringify and jQuery.parseJSON to serialize and deserialized using some framework like knockout.js for the databinding etc. I have extensive experience doing these kinds of things and used to think server-side so much. Now I only see the server-side allowing me to CRUD JSON data as that's what I use it for when doing web apps.

您必须使用JSON.stringify和jQuery.parseJSON在JavaScript客户端上进行大量开发,以使用像knockout.js这样的框架进行序列化和反序列化,以进行数据绑定等。我有丰富的经验做这些事情并且习惯于认为服务器这么多。现在我只看到服务器端允许我使用CRUD JSON数据,就像我在使用Web应用程序时所使用的那样。

#1


4  

HTML5 localStorage and sessionStorage can house up to 5 MB or more depending on the browser for a domain.

HTML5 localStorage和sessionStorage最多可容纳5 MB或更多,具体取决于域的浏览器。

HTML5 ApplicationCache in particular is good for what you want as you can specify a manifest that is checked for modifications each request but only that file is accessed every time while your cached resources will not be requested unless directed to do so, saving tons of bandwidth. If you served the manifest file via server-side dynamic programming, you could easily implement a caching strategy by simply changing the manifest file timestamp or comment within the doc as you get new data in. The manifest file could be dynamically served based on a user's cookie so you could in affect have sets of data that you have per user if you needed to compartmentalize the data.

特别是HTML5 ApplicationCache适用于您想要的内容,因为您可以指定每个请求检查修改的清单,但每次访问时都只访问该文件,除非有指示这样做,否则会节省大量带宽。如果您通过服务器端动态编程提供清单文件,则只需在获取新数据时更改清单文件时间戳或文档内的注释即可轻松实现缓存策略。清单文件可以根据用户的动态提供如果您需要划分数据,那么您可能会影响每个用户拥有的数据集。

You would have to develop heavy on the JavaScript client-side with JSON.stringify and jQuery.parseJSON to serialize and deserialized using some framework like knockout.js for the databinding etc. I have extensive experience doing these kinds of things and used to think server-side so much. Now I only see the server-side allowing me to CRUD JSON data as that's what I use it for when doing web apps.

您必须使用JSON.stringify和jQuery.parseJSON在JavaScript客户端上进行大量开发,以使用像knockout.js这样的框架进行序列化和反序列化,以进行数据绑定等。我有丰富的经验做这些事情并且习惯于认为服务器这么多。现在我只看到服务器端允许我使用CRUD JSON数据,就像我在使用Web应用程序时所使用的那样。