简体   繁体   English

ASP.NET服务器缓存

[英]ASP.NET server caching

I have a web application that runs on windows server 2008 r2. 我有一个在Windows Server 2008 R2上运行的Web应用程序。 One of the pages takes too long to process when it first loads. 第一次加载时,其中一个页面处理时间太长。 It takes around 15 seconds and after that its almost instant. 大约需要15秒,此后几乎是瞬间。 What happens is that the w3wp.exe process jumps from under 200 MB of RAM to 700 MB of RAM in this time. 发生的是,这次w3wp.exe进程从不足200 MB的RAM跳到了700 MB的RAM。 That is fine, the page is huge and requires that amount of memory. 很好,页面很大,需要一定数量的内存。 After those 15 seconds it switches back to around 200 MB of RAM and if anyone accesses that page it renders almost instant. 在那15秒之后,它会切换回大约200 MB的RAM,如果有人访问该页面,它将几乎立即呈现。 Its only the first time it renders regardless of who requested it. 无论是谁请求,它都是第一次渲染。 Now after some time (minutes if not tens of minutes) when someone requests the page again, it does the same thing - 15 seconds to process and it jumps to 700 MB of RAM. 现在,经过一段时间(如果不是几十分钟,则是几分钟,几分钟),当有人再次请求该页面时,它执行相同的操作-处理15秒,然后跳转到700 MB RAM。

I want somehow to preserve the cache of 700 MB so it doesn't expire. 我想以某种方式保留700 MB的缓存,这样它就不会过期。 Even after it falls back to 200 MB of RAM the page loads instant, but my guess is that that's why after a longer period of time it 'expires' and has to render it again. 即使回落到200 MB RAM之后,页面也会立即加载,但是我的猜测是这就是为什么在较长时间后页面“过期”并必须再次渲染的原因。 I have read about @outputcache but i'm not sure this is what i need. 我已经读过有关@outputcache的信息,但是我不确定这是我所需要的。 And there are many types of caching . 并且有很多类型的缓存 Could someone point me in the right direction? 有人可以指出我正确的方向吗? I'm not worried about the memory consumption or anything else, i just don't want a user to wait 15 seconds to load it even if it doesn't happen too often. 我不担心内存消耗或其他任何事情,我只是不希望用户等待15秒来加载它,即使这种情况很少发生也是如此。 Thanks! 谢谢!

PS: application written in C# under ASP.NET 4.0 PS:在ASP.NET 4.0下用C#编写的应用程序

Your page gets compiled the first time it is being called after the start of the application pool ( http://msdn.microsoft.com/en-us/library/ms366723(v=vs.100).aspx ). 在应用程序池启动后,第一次调用页面时便对其进行了编译( http://msdn.microsoft.com/zh-cn/library/ms366723(v=vs.100).aspx )。

The default time-out of an iddle application pool before it shuts down is 20 minutes: http://technet.microsoft.com/en-us/library/cc771956(v=ws.10).aspx 中间应用程序池关闭之前的默认超时为20分钟: http ://technet.microsoft.com/zh-cn/library/cc771956(v=ws.10) .aspx

If a new request is made after the application pool has shut down, the application pool needs to be restarted and has to compile your page again. 如果在应用程序池关闭后发出了新请求,则需要重新启动应用程序池,并且必须再次编译您的页面。

Besides improving caching in your application, you can do 2 things: 除了改善应用程序中的缓存之外,您还可以做两件事:

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM