0
因此,我正在开发的程序为用户提供了查看各种数据的不同Javascript实现的图形表示(使用WebGL,JIT等)的可能性。服务器端是用python编写的,使用genshi + buffet的cherrypy。从服务器获取数据到Javascript的最快方法
问题是,许多文件真的很大,实际数据到达Javascript的时间开始成为一个问题。
到目前为止,这种方法是有服务器端暴露的CherryPy方法:
@cherrypy.expose
@logged()
def read_server_file(self, coded_path):
"""
Retrieve file from Local storage, having a File System Path.
"""
try:
my_file = open(url2path(coded_path), "rb")
result = my_file.read()
my_file.close()
return result
except Exception, excep:
self.logger.error("Could not retrieve file from path:" +
str(coded_path))
self.logger.exception(excep)
这只是获取磁盘上的实际文件,从文件返回数据。而在客户端:
function getFile(fileName) {
oxmlhttp = null;
try {
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/plain");
} catch(e) {
try {
oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
return null;
}
}
if (!oxmlhttp) return null;
try {
oxmlhttp.open("GET", fileName, false);
oxmlhttp.send(null);
} catch(e) {
return null;
}
return oxmlhttp.responseText;
}
所以我的问题是,你知道任何更快/更有效的方式来获得所需的数据吗?
问候, 波格丹
大多数Web服务器都应该有一个选项,可以直接提供静态文件,而无需通过Web应用程序层。我不知道这是否会对你的情况产生很大影响,但值得注意。 –