我如何code我的ASP.NET页面并行跨主机名下载? [英] How do I code my ASP.NET page to parallelize downloads across hostnames?

查看:69
本文介绍了我如何code我的ASP.NET页面并行跨主机名下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

网页速度测试告诉我,我需要分发我的查询整个DNS域名,以加快渲染。

Google Page Speed test tells me I need to distribute my queries across DNS Domain names to speed up rendering.

由于我做开发离线,我想找到一个解决方案,我分配在不同的主机名静态内容(IMG,CSS,JS),当我在下线飞机仍然可以工作。

Since I do development offline, I'd like to find a solution that will distribute my static content (img, CSS, js) across different hostnames, and will still work when I'm offline in an airplane.

问:
我怎样才能code我的网页使用相对路径(或本地主机)下线的时候,和5主机之间始终如一地发送静态内容的请求?看完<一个href=\"http://webmasters.stackexchange.com/questions/2809/how-can-i-tell-google-analytics-to-not-use-cookies-for-my-sub-domain\">this我想链接直接与此类似:

Q: How can I code my page to use relative paths (or local host) when offline, and to consistently send static content requests among 5 hosts? After reading this I'd like the url to be similar to this:

当在线:动态内容结果
www.TLSAdmin.com
搜索结果
当在线:静态内容结果
 static1.TLSAdmin-Static.com结果
 static2.TLSAdmin-Static.com结果
 static3.TLSAdmin-Static.com结果
 static4.TLSAdmin-Static.com

When Online: Dynamic content
www.TLSAdmin.com

When Online: Static content
static1.TLSAdmin-Static.com
static2.TLSAdmin-Static.com
static3.TLSAdmin-Static.com
static4.TLSAdmin-Static.com

脱机时:所有内容结果
 本地主机

When Offline: All content
localhost

我倒是preFER使它从而使简称主机将是一致后刷新页面来利用浏览器缓存。所以随机guid.TLSAdmin.com将不会是一个好主意。

I'd prefer to make it so that the referred to hostname will be consistent after a page refresh to leverage browser caching. So a random guid.TLSAdmin.com will not be a good idea.

推荐答案

这个怎么样:

1)code你链接到静态资源,例如,[HOSTNAME] /Images/myimage.jpg结果
2)创建要么是HTTP模块或页面的基类,它实现一个响应滤波器。结果
3)该过滤器应使用正则表达式找到[HOSTNAME]的所有实例,并与其他功能代替。

1) Code all you links to static resources as, for example, [HOSTNAME]/Images/myimage.jpg
2) Create either an HTTP module or a base class for your pages which implements a response filter.
3) That filter should use a regex to find all instances of [HOSTNAME] and replace with an alternative.

该过滤器可以包括逻辑来检查当前主机为localhost,然后只需插入localhost作为主机名。随机化的其他主机名的分配,同时保持高速缓存能力,你可以做到以下几点:

The filter could include logic to check if the current hostname is localhost and then just insert localhost as the hostname. To randomise the distribution of the other hostnames whilst maintaining cacheability you could do the following:

1)有替代主机名列表结果
2)你需要一个更复杂的正则表达式/语法找到[HOSTNAME],并找到该文件的名称,以及结果
3)创建的文件的全路径的散列。这可能是非常简单的,就像数着ASCII $ C路径中的每个字符$ CS和主机名的查找模块#结果
4)使用散列值来接从列表的主机名。

1) Have a list of alternative hostnames
2) You'd need a more complex regex/syntax to find [HOSTNAME] and also locate the file name as well
3) Create a hash of the full path of the file. This could be really simple, like counting the ascii codes of each character in the path and finding the module # of hostnames
4) Use the hash value to pick the hostname from the list.

有了这个,你应该得到在每个主机+相同的资源请求将始终从同一台主机提供的A S $ P $垫,因此它可以被缓存。

With this, you should get a spread of requests across each hostname + the same resource will always be served from the same host so it can be cached.

这篇关于我如何code我的ASP.NET页面并行跨主机名下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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