机身前发送头加载CSS和JS尽快 [英] Send head before body to load CSS and JS asap

查看:178
本文介绍了机身前发送头加载CSS和JS尽快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道是否有人已经找到了一种方法来在中间发送渲染头标签,这样的CSS和JavaScript渲染完成的页面加载之前?我们的页面约需523ms要呈现和未加载资源直到接收到页面。我已经做了很多的PHP,这是可能的脚本结束前刷新缓冲区。我试图添加一个 Response.flush()在母版的Page_Load 的结束,但页面布局可怕的是后来打破。我见过很多使用更新面板使用AJAX之后发送内容的人,但我不太知道它会对SEO有什么影响。

I wonder if anyone has found a way to send at mid rendering the head tag so CSS and Javascript are loaded before the page render has finished? Our page takes about 523ms to be rendered and resources aren't loaded until the page is received. I've done a lot of PHP and it is possible to flush the buffer before the end of the script. I've tried to add a Response.flush() at the end of the Masterpage page_load, but the page layout is horribly broken afterward. I've seen a lot of people using an update panel to send the content using AJAX afterward but I don't quite know what impact it would have on the SEO.

如果我没有找到一个解决办法我想我得走了反向代理路线,找到一种方法无效代理缓存,当网页内容的变化。

If I don't find a solution I guess I'd have to go the reverse proxy route and find a way to invalidate the proxy cache when the pages content change.

推荐答案

不要放在身后,但你的HTML页面作为code中的同花顺:

Do not place the Flush on code behind but on your html page as:

</head>
<%Response.Flush();%>
<body >

这可以像在页面上fleekering效果,所以你可以尝试连招齐平低一点的网页。

This can make something like fleekering effect on the page, so you can try to move the flush even a little lower to the page.

同样在雅虎页面提示在刷新缓冲区早期结果
http://developer.yahoo.com/performance/rules.html

Also on Yahoo tips page at Flush the Buffer Early
http://developer.yahoo.com/performance/rules.html

此外,你可以像CSS和JavaScript的静态内容添加客户端缓存。在这个页面中拥有所有的途径所有的IIS版本。

Additionally you can add client cache on static content like the css and javascript. In this page have all the ways for all iis versions.

http://www.iis.net/ConfigReference/system.webServer/ staticContent / clientCache

更多的认为,我建议你这样做后,我看到你的网页是把所有的CSS和JavaScript在每一个文件中的一个。 ,还可以使用缩小的,以尽量减少他们。

One more think that I suggest you to do after I see your pages is to place all css and javascript in one file each. And also use minified to minimize them.

我用这个缩小的 http://www.asp.net/ajaxlibrary/Download.ashx 有很好的效果和实时精缩。

I use this minified http://www.asp.net/ajaxlibrary/Download.ashx with very good results and real time minified.

这篇关于机身前发送头加载CSS和JS尽快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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