我可以刷新缓冲区早期使用ASP.NET? [英] Can I Flush the Buffer Early Using ASP.NET?

查看:85
本文介绍了我可以刷新缓冲区早期使用ASP.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从雅虎Speeing您的web网站最佳实践包括以下建议:


  

当用户请求页面时,它可以随时随地从200至500毫秒的后端服务器缝合在一起的HTML页面。在此期间,该浏览器是空闲,因为它等待数据到达。在PHP中有函数flush()。它可以让你把你的部分准备HTML响应到浏览器,使浏览器可以开始获取组件,同时你的后端是忙于HTML页面的其余部分。这样做的好处主要是看到忙碌的后端或轻前端。


  
  

考虑冲洗不好的地方就是后头部右侧,因为头部的HTML通常更容易产生和它允许你以包括浏览器启动并行获取任何CSS和JavaScript文件,而后端仍在处理。


  
  

例如:


  ...<! -  CSS,JS  - >
< /头>
< PHP冲水(); ?>
<身体GT;
...<! - 内容 - >

请注意在此刷新后这里是头标记被写入后点。这使得有很大的意义因此而页面的其余部分呈现,并担任该浏览器可以开始加载图像和脚本。

有没有办法头部后刷新(或页面的任何其他部分)明确使用ASP.NET?


解决方案

您应该可以把下面的在你的页面头部的结束和身体语句的开始之间:

 <%Response.Flush(); %GT;

不过,要小心在这里,你正在使用脚本管理器或任何其他类型的控制,将自身注册为在html的头部部分输出的事件。

Best Practices for Speeing Up Your Web Site from Yahoo includes the following recommendation:

When users request a page, it can take anywhere from 200 to 500ms for the backend server to stitch together the HTML page. During this time, the browser is idle as it waits for the data to arrive. In PHP you have the function flush(). It allows you to send your partially ready HTML response to the browser so that the browser can start fetching components while your backend is busy with the rest of the HTML page. The benefit is mainly seen on busy backends or light frontends.

A good place to consider flushing is right after the HEAD because the HTML for the head is usually easier to produce and it allows you to include any CSS and JavaScript files for the browser to start fetching in parallel while the backend is still processing.

Example:

... <!-- css, js -->
</head>
<?php flush(); ?>
<body>
... <!-- content -->

Note the point at which the flush occurs here is after the head tag is written. This makes a lot of sense so the browser can begin loading images and scripts while the remainder of the page is rendered and served.

Is there a way to flush after the head (or any other part of the page) explicitly using ASP.NET?

解决方案

You should be able to put the following in your page between the end of the head and the beginning of the body statement:

<% Response.Flush(); %>

However, be careful here in the event that you are using a script manager or any other kind of control that will register itself for output in the head section of the html.

这篇关于我可以刷新缓冲区早期使用ASP.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆