简体   繁体   English

我如何在客户端浏览器中使用缓存?

[英]how i can use cache in client side browser?

i have a website who have a list of information on the front page. 我有一个网站,其首页上有信息列表。 the left side and right side bar have some information who rarely to update so i thing that i need to store them in cache. 左侧和右侧的栏上有一些很少更新的信息,所以我需要将它们存储在缓存中。

how i can store them in cache in ASP.NET MVC 3. any suggetion for doing this. 我如何将它们存储在ASP.NET MVC 3的缓存中。执行此操作的任何建议。

You can use OutputCacheAttribute to store the return values of the controller in the web server cache. 您可以使用OutputCacheAttribute将控制器的返回值存储在Web服务器缓存中。 What this does is the next the controller action is invoked the cached data is returned instead of executing the method. 下一步是调用控制器操作时,将返回缓存的数据,而不是执行该方法。 Since you also mention you want to cache this on the client browser you might want to look at Google Gears or other solutions for that. 由于您也提到要在客户端浏览器上缓存它,因此您可能需要查看Google Gears或其他解决方案。

David Hayden has a blog post on partial page OutputCache http://davidhayden.com/blog/dave/archive/2011/01/25/partialpageoutputcachingaspnetmvc3.aspx David Hayden在部分页面OutputCache上有一篇博客文章http://davidhayden.com/blog/dave/archive/2011/01/25/partialpageoutputcachingaspnetmvc3.aspx

And Phil Haack has an article on donut hole caching (based on an older version of MVC) http://haacked.com/archive/2009/05/12/donut-hole-caching.aspx 菲尔·哈克(Phil Haack)则发表了一篇关于甜甜圈孔缓存的文章(基于旧版本的MVC) http://haacked.com/archive/2009/05/12/donut-hole-caching.aspx

I don't think you want to store them in the browser cache, but rather in the server cache so you don't need the server to regenerate the content each time. 我认为您不想将它们存储在浏览器缓存中,而是存储在服务器缓存中,因此您不需要服务器每次都重新生成内容。 Partial page caching on the client would be hard to do unless you were doing ajax calls. 除非进行ajax调用,否则很难在客户端上进行部分页面缓存。 In that case you could cache the result from an ajax call and it would be reused by subsequent ajax calls. 在这种情况下,您可以缓存来自ajax调用的结果,并且随后的ajax调用将重用该结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在客户端(浏览器)中使用Flux模式? - How to use Flux pattern in client side(browser)? 如何获得客户端日期和货币格式? - How can I get the client side date and currency formats? 注销后如何清除浏览器缓存(内存/磁盘缓存)? - How can I clear browser cache (memory / disk cache) after logout? 我可以在浏览器中缓存https资源吗? - can I cache https resources in browser? 在客户端缓存大量的json结果 - Cache large volume of json result on client side 如何清除整个表单客户端,或者正确的方法是调用控制器并在那里清除模型? - How can I clear the entire form client side or would the proper way be to call the controller and clear the model there? 如何在ASP.NET MVC中禁用客户端和代理缓存? - How can I disable client side and proxy caching in ASP.NET MVC? 我如何从客户端检查MVC中的validatemessagefor是否有值(如果模型无效) - How can i check validationmessagefor in mvc has a value (if model is not valid) from the client side 如何在ASP.NET MVC项目中为knockout生成客户端视图模型? - How can I generate client-side view models for knockout in an ASP.NET MVC project? 如何以编程方式触发Razor视图设置的客户端验证? - How can I programmatically trigger client side validation set up by a Razor view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM