CN103139298A - Method for transmitting network data and device - Google Patents

Method for transmitting network data and device Download PDF

Info

Publication number
CN103139298A
CN103139298A CN 201310040161 CN201310040161A CN103139298A CN 103139298 A CN103139298 A CN 103139298A CN 201310040161 CN201310040161 CN 201310040161 CN 201310040161 A CN201310040161 A CN 201310040161A CN 103139298 A CN103139298 A CN 103139298A
Authority
CN
Grant status
Application
Patent type
Prior art keywords
file
compressed
terminal
css
javascript
Prior art date
Application number
CN 201310040161
Other languages
Chinese (zh)
Other versions
CN103139298B (en )
Inventor
赵宏波
Original Assignee
北京京东世纪贸易有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date

Links

Abstract

The invention discloses a method for transmitting network data and a device. The method for transmitting the network data and the device are capable of improving efficiency of updating of a page from developing to testing, modifying till online operation and reducing error rate of the page. The method for transmitting the network data comprises the following steps. A server responds to a request for visiting a network address of a terminal and sends webpage source codes to the terminal. The webpage source codes comprise instructions used for designated javascript files and/or cascading style sheet (CSS) files. The server responds to request information generated based on the instructions of the terminal and provides compressed files for the terminal. The compressed files comprise the javascript files and/or the CSS files of the designated by the instructions.

Description

一种传输网络数据的方法和装置技术领域[0001 ] 本发明涉及一种传输网络数据的方法和装置。 Method and apparatus for transmitting network data Technical Field [0001] The present invention relates to a network data transmission method and apparatus. 背景技术[0002] 在基于B/S架构的软件开发过程中,经常需要用到大量的javascript框架、控件、自定义的javascript代码和大量的层叠样式表文件(CSS),为了提高终端即浏览器的下载速度,在页面开发过程中,开发人员将网页中用到的多个javascript和/或css文件通过第三方工具压缩合并为一个压缩文件并且对应于该页面保存下来,这样页面上线之后,浏览器在解析网页源代码并且发送请求时,服务器获取上述压缩文件然后提供给浏览器。 [0002] In the process of software development based on B / S structure, it is often requires a great deal of javascript framework, control, custom javascript code and a large number of cascading style sheet file (the CSS), i.e., the terminal in order to improve the browser after multiple javascript and / or css file download speed in page development process, developers will be used in web page by third-party tools into one compressed file compression and saved corresponding to the page, on this page line browsing parsing the page in the source code and send the request, the server then acquires the compressed file to the browser. [0003] 如果网页内容被修改并且涉及了用到的javascript和/或css文件,贝U开发人员重新制作上述的压缩文件,并且相应修改页面中的其他内容例如压缩文件的文件名。 [0003] If the content has been modified and involve javascript and / or css files, shell U developers to re-create compressed files mentioned above, and accordingly modify other content pages such as compressed file name used. [0004] 在页面从开发到测试、修改直至上线运行中的更新,页面内容通常要修改多次,按照现有的上述做法,需开发人员多次制作压缩文件,导致效率低下以及出错率增加。 [0004] In the page from development to testing, modification updating until the on-line operation, to modify the page content is typically several times, according to the conventional practice, the developer needs to create multiple compressed file, and inefficient to increase the error rate. 发明内容[0005] 有鉴于此,本发明提供一种传输网络数据的方法和装置,能够提高页面从开发到测试、修改直至上线运行中的更新的效率,并且减小页面的出错率。 SUMMARY OF THE INVENTION [0005] Accordingly, the present invention provides a network data transmission method and apparatus, the page can be improved from development to testing, on-line modification efficiency until the update operation, and to reduce the error rate of the page. [0006] 为实现上述目的,根据本发明的一个方面,提供了一种传输网络数据的方法。 [0006] To achieve the above object, according to one aspect of the invention, there is provided a method of data transmission network. [0007] 本发明的传输网络数据的方法包括:服务器响应于终端的访问网络地址的请求,向所述终端发送网页源代码,所述网页源代码中包含用于指定javascript文件和/或层叠样式表(CSS)文件的指令;服务器响应于所述终端根据所述指令生成的请求信息,将压缩文件提供给所述终端,所述压缩文件中包含有所述指令指定的javascript文件和/或CSS文件。 [0007] network data transmission method of the present invention comprises: a server in response to a request to access the network address of the terminal, and transmits to the terminal page source code, the source code contains the page for specifying a javascript file and / or Cascading Style instruction sheet (CSS) file; server terminal in response to the request according to the instruction information generated by the compressed file to the terminal, the compressed javascript file contains the instructions specified and / or CSS file. [0008] 可选地,将压缩文件提供给所述终端的步骤包括:从分布式缓存中获取压缩文件然后发送给所述终端;在所述分布式缓存中不存在所述压缩文件的情况下,从文件系统中获取所述指令指定的javascript文件和/或CSS文件然后压缩得到所述压缩文件,再将该压缩文件发送给所述终端并且保存在所述分布式缓存中。 [0008] Alternatively, the compressed file to said terminal comprises the step of: obtaining files from the distributed cache is then transmitted to the terminal; the case where the compressed file does not exist in the distributed cache obtaining the instructions from a file system specified javascript file and / or CSS file is then compressed to obtain the compressed file, and then transmits the compressed file to the terminal and stored in the distributed cache. [0009] 可选地,压缩得到所述压缩文件的步骤之后,还包括:设置有效时长;从所述压缩文件被保存在所述分布式缓存中起经过所述有效时长后,将所述压缩文件从所述分布式缓存中删除。 After [0009] Optionally, the step of compressing the compressed file obtained, further comprising: setting a valid duration; from the compressed file is saved after a lapse of the valid length in the distributed cache, the compression distributed file is deleted from the cache. [0010] 可选地,压缩得到所述压缩文件的步骤包括:将从文件系统中获取的所述指令指定的javascript文件和/或CSS文件进行压缩处理,并且根据获取的javascript文件和/或CSS文件的文件名得到唯一对应于获取的javascript文件和/或CSS文件的字段,将该字段作为所述压缩处理得到的压缩文件的文件名。 [0010] Alternatively, the compression of the resulting compressed file comprises: the instruction acquired from the file system designated javascript file and / or CSS file compression process, and in accordance with the acquired javascript file and / or CSS to give a unique name of a file corresponding to the acquired javascript file and / or field CSS file, the file name of the compressed file field as the compression processing obtained. [0011] 根据本发明的另一方面,提供了一种传输网络数据的装置。 [0011] According to another aspect of the present invention, there is provided an apparatus for data transmission network. [0012] 本发明的传输网络数据的装置包括:第一接收模块,用于接收终端的访问网络地址的请求;第一发送模块,用于向所述终端发送网页源代码,所述网页源代码中包含用于指定javascript文件和/或层叠样式表(CSS)文件的指令;第二接收模块,用于接收所述终端根据所述指令生成的请求信息;第二发送模块,用于将压缩文件提供给所述终端,所述压缩文件中包含有所述指令指定的javascript文件和/或CSS文件。 [0012] network data transmission apparatus of the present invention comprises: a first request receiving module, configured to receive access to the network address of the terminal; a first sending module, configured to send a page source code to the terminal, the page source code contains a javascript file and specify or instructions / Cascading style Sheets (CSS) file; a second receiving module configured to receive the request information generated by the terminal according to the instruction; second sending module, configured to archive to the terminal, the compressed javascript file and / or CSS file contains the file specified by the instruction. [0013] 可选地,所述第二发送模块还用于:从分布式缓存中获取压缩文件然后发送给所述终端;在所述分布式缓存中不存在所述压缩文件的情况下,从文件系统中获取所述指令指定的javascript文件和/或CSS文件然后压缩得到所述压缩文件,再将该压缩文件发送给所述终端并且保存在所述分布式缓存中。 [0013] Alternatively, the second sending module is further configured to: obtain files from the distributed cache is then transmitted to the terminal; the case where the compressed file does not exist in the distributed cache, from acquiring the file system specified by the instruction javascript file and / or CSS file is then compressed to obtain the compressed file, and then transmits the compressed file to the terminal and stored in the distributed cache. [0014] 可选地,所述第二发送模块还用于:设置有效时长;从所述压缩文件被保存在所述分布式缓存中起经过所述有效时长后,将所述压缩文件从所述分布式缓存中删除。 [0014] Alternatively, the second sending module is further configured to: set the valid duration; from the compressed file is stored in the distributed cache after the date of the effective duration passes, the compressed file from the said distributed cache deleted. [0015] 可选地,所述第二发送模块还用于:将从文件系统中获取的所述指令指定的javascript文件和/或CSS文件进行压缩处理,并且根据获取的javascript文件和/或CSS文件的文件名得到唯一对应于获取的javascript文件和/或CSS文件的字段,将该字段作为所述压缩处理得到的压缩文件的文件名。 [0015] Alternatively, the second sending module is further configured to: the instruction acquired from the file system designated javascript file and / or CSS file compression process, and in accordance with the acquired javascript file and / or CSS to give a unique name of a file corresponding to the acquired javascript file and / or field CSS file, the file name of the compressed file field as the compression processing obtained. [0016] 根据本发明的技术方案,服务器响应于终端的访问网络地址的请求,向终端发送网页源代码,该网页源代码中包含用于指定javascript文件和/或层叠样式表(CSS)文件的指令;然后服务器响应于该终端根据上述指令生成的请求信息,将压缩文件提供给该终端,该压缩文件中包含有上述指令指定的javascript文件和/或CSS文件,从而在网页中事先指定要提供的javascript文件和/或CSS文件,无需网页开发人员手动制作压缩文件,而是在网页被浏览时临时由服务器制作压缩文件,并且在修改页面、改变要提供的javascript文件和/或CSS文件的情况下,只需修改网页代码,仍无需网页开发人员手动制作压缩文件,提高了网页开发、修改和测试的效率;并且减小了人工参与的程度,于是减小了页面的出错率。 [0016] According to the present invention, the server response to a request to access the network address of the terminal, the terminal transmits page source code, for specifying the page source comprises javascript file and / or Cascading Style Sheet (CSS) file code command; then the server in response to the terminal according to the request information of the generated command, the compressed file to the terminal, the compressed file contains the command specified javascript file and / or CSS files, to specify in advance in the web page to be provided javascript files and / or CSS files without web developers to make the compressed file manually, but temporary zip file from the server made when the page was viewed, and in the case of modifying the page, change the javascript files to be provided and / or CSS files next, simply modify the page code, web developers still do not need to manually make compressed files, improved web development, modification and testing efficiency; and reduce the degree of human intervention, thus reducing the error rate of the page. 并且根据本发明实施例的技术方案,优先从读写速度较快的缓存中读取现成的压缩文件,如果没有该压缩文件再临时读取javascript文件和/或CSS文件并压缩得到压缩文件,并且将得到的压缩文件保存到缓存中,这样,只有当页面被第一次浏览时需要临时生成压缩文件,使页面的呈现速度受到影响以外,页面被再次浏览时因为缓存中已经保存了压缩文件所以呈现速度较快,提高了页面上线运行的效率。 According to the embodiment and the embodiment of the present invention, the priority is read from the compressed file ready faster read and write cache, if not read the temporary file and then compressed javascript file and / or CSS file and the compressed file is compressed, and save the compressed file will get to the cache, so that only when the page is first necessary to temporarily generate a compressed file browser, the page rendering speed is affected outside the browser when the page is saved again because the cache has been so compressed file rendering faster, improve the efficiency of the line to run the page. 附图说明[0017] 附图用于更好地理解本发明,不构成对本发明的不当限定。 BRIEF DESCRIPTION [0017] The accompanying drawings for a better understanding of the present invention, without unduly limiting the present invention. 其中:[0018] 图1是根据本发明实施例的传输网络数据的方法的基本步骤的示意图;[0019] 图2是根据本发明实施例的传输网络数据的装置的示意图。 Wherein: [0018] FIG. 1 is a diagram showing the basic steps of the method of the embodiment of a data transmission network of the present invention; [0019] FIG. 2 is a schematic diagram of a data transmission network apparatus embodiment in accordance with the embodiment of the invention. 具体实施方式[0020] 以下结合附图对本发明的示范性实施例做出说明,其中包括本发明实施例的各种细节以助于理解,应当将它们认为仅仅是示范性的。 DETAILED DESCRIPTION [0020] DESCRIPTION OF THE DRAWINGS made below of exemplary embodiments of the present invention, including various details of the embodiments to assist in understanding the present invention, they should be regarded as merely exemplary. 因此,本领域普通技术人员应当认识至IJ,可以对这里描述的实施例做出各种改变和修改,而不会背离本发明的范围和精神。 Accordingly, those of ordinary skill in the art to be appreciated IJ, changes may be made to the embodiments and various modifications described herein, without departing from the scope and spirit of the invention. 同样,为了清楚和简明,以下的描述中省略了对公知功能和结构的描述。 Also, for clarity and conciseness, the following description is omitted the description of known functions and Structure. [0021] 图1是根据本发明实施例的传输网络数据的方法的基本步骤的示意图。 [0021] FIG. 1 is a diagram showing the basic steps of the method of data transmission network of the embodiment of the present invention. 如图1所示,本发明实施例的传输网络数据的方法主要包括如下的步骤Sll至步骤S14。 1, the network data transmission method of an embodiment of the present invention mainly comprises the following step Sll to step S14. [0022] 步骤Sll:终端向服务器发送访问网络地址的请求。 [0022] Step Sll: sending a request to access the network address of a terminal to a server. [0023] 步骤S12:服务器向终端发送网页源代码。 [0023] Step S12: The server sends to the terminal the page source. 在本步骤中,作为向步骤Sll中的请求的响应,服务器将网页源代码发送给终端。 In this step, as a response to the request in step Sll, the web server source code to the terminal. 网页源代码中包含用于指定javascript文件和/或CSS文件的指令。 Page source code containing instructions for specifying a javascript file and / or a CSS file. [0024] 步骤S13:终端解析网页源代码并且向服务器发送请求信息。 [0024] Step S13: The terminal parses the page source and the transmission request information to the server. 本步骤中,终端解析接收到的网页源代码,在解析到步骤S12中所述的指令后,根据该指令生成请求信息以请求获得相应的javascript文件和/或CSS文件。 In this step, the terminal parses the received web page source code, in S12 after the instruction to the analysis step, according to the instruction generation request information corresponding to request a javascript file and / or a CSS file. [0025] 步骤S14:服务器将压缩文件提供给终端。 [0025] Step S14: The compressed file server to the terminal. 在本步骤中,作为向步骤S13中的请求信息的响应,服务器有两种方式向终端提供压缩文件。 In this step, as a response to the request information in step S13, the server there are two ways to provide the compressed file to the terminal. 如果服务器的分布式缓存中已经有相应的压缩文件,则直接将该压缩文件发送给终端;否则从文件系统中读出终端所请求的、实际上也是步骤S12中的指令所指定的各个javascript文件和/或CSS文件,然后将这些文件压缩,得到上述的相应的压缩文件,再将该压缩文件发送给终端。 If the distributed cache server has the appropriate compressed file, the compressed file directly to the transmitting terminal; otherwise, reading out respective javascript file requested by the terminal, the step S12 is actually specified by the instruction from the file system and / or a CSS file, and these files are compressed to give the above respective compressed files, and then transmits the compressed file to the terminal. [0026] 从上述步骤可以看出,在网页中事先指定要提供的javascript文件和/或CSS文件,就无需网页开发人员手动制作压缩文件,而是在网页被浏览时临时由服务器制作压缩文件,并且在修改页面、改变要提供的javascript文件和/或CSS文件的情况下,只需修改网页代码,仍无需网页开发人员手动制作压缩文件,提高了网页开发、修改和测试的效率;并且减小了人工参与的程度,于是减小了页面的出错率。 [0026] As can be seen from the above steps, specified in advance javascript files and / or CSS file to be provided in a web page, web developers do not need to manually make a compressed file, the compressed file from the server but temporary production when the page was viewed, and in the case of modifying the page, change the javascript files and / or CSS file to be provided, simply modify the page code, web developers still do not need to manually make compressed files, improved web development, modification and testing efficiency; and reduce the degree of human intervention, thus reducing the error rate of the page. [0027] 而且从上述步骤中还可以看出,由于是在浏览过程中临时制作压缩文件,所以对于浏览时的页面在终端的呈现速度有一定的影响,所以在步骤S14中,优先从读写速度较快的缓存中读取现成的压缩文件,如果没有该压缩文件再临时读取javascript文件和/或CSS文件并压缩得到压缩文件,并且将得到的压缩文件保存到缓存中。 [0027] and can also be seen from the above step, since the production is temporary compression during browsing files, so the page when browsing to a certain extent in the presentation speed of the terminal, so in step S14, the priority from the reader faster cache read existing compressed file, the compressed file and then if there is no temporary files read javascript and / or CSS files get compressed and compressed file, and save the resulting compressed file into the cache. 这样,只有当页面被第一次浏览时需要临时生成压缩文件,使页面的呈现速度受到影响以外,页面被再次浏览时因为缓存中已经保存了压缩文件所以呈现速度较快,提高了页面上线运行的效率。 In this way, only when the page is first necessary to temporarily generate a compressed file browser, the page rendering speed is affected outside the browser when the page is saved again because the cache has been presented so compressed file faster, improve the running line on the page s efficiency. [0028] 需要说明的是,在步骤S13中,通常的浏览器都会先从本地缓存中查找需要的javascript文件和/或CSS文件,在没有查找到的情况下再执行步骤S13中的向服务器发送请求信息。 [0028] It should be noted that, in step S13, the browser will usually find the required javascript files and / or CSS files start with the local cache, and then sent to the server to perform step S13 in the case of not found request information. [0029] 为了保证javascript文件和/或CSS文件与压缩这些javascript文件和/或CSS文件所得到的压缩文件之间的唯一对应性,可以在压缩完成之后,根据被压缩的javascript文件和/或CSS文件的文件名得到唯一对应于这些javascript文件和/或CSS文件的字段,例如可以将这些javascript文件和/或CSS文件的文件名首尾相连之后进行散列计算,将得到的散列值作为压缩文件的文件名。 [0029] In order to guarantee a unique correspondence between a javascript file and / or a compressed file and CSS file compress javascript file and / or CSS document obtained after the compression can be completed, according to the compressed javascript file and / or CSS to give a unique name of a file corresponding to the javascript file and / or CSS document fields, for example, the file name javascript file and / or a CSS file hash calculation performed after connected end to end, the hash value obtained as a compressed file file name. 相应地,服务器在步骤S13中收到请求信息后,根据请求信息中的javascript文件和/或CSS文件的文件名,进行相同方式的处理例如相同方式的散列计算从而得到相应的压缩文件的文件名。 Accordingly, in step S13, the server receives the request message, the file name javascript file request information and / or CSS file, for example, be treated in the same manner as the hash calculated in the same manner to obtain the corresponding file the compressed file name. [0030] 因为页面即使在上线运行期间也有可能被进一步修改,所以可以对保存在缓存中的压缩文件设置有效时长,在生成压缩文件并且保存在缓存时开始计时,经过上述有效时长后就从缓存中删除该压缩文件。 [0030] is further modified because the page even during on-line operation is also possible, so long valid may be provided for the compressed file stored in the cache, the generated compressed file and stored in a cache start timing, after the effective duration after from the buffer To remove the compressed file. [0031] 根据本实施例的上述方案,在实现中,可以选用velocity自定义标签作为端统一的调用方式,合并压缩引擎可采用yuicompressor,对压缩合并后的文件内容可采用memcahced作为缓存,同时可以通过实现不同的缓存接口来进行缓存框架的平滑切换。 [0031] According to the above embodiment of the present embodiment, the implementation may be chosen as a terminal velocity custom tag is called a unified, combined compression engine YUICompressor employed, the compressed content file can be merged memcahced as the cache, while smooth switching to buffer framework by implementing various cache interface. 当然在开发页面时不限于采用velocity模板引擎,其他开发工具也可以使用。 Of course, in the development of the page is not limited to the use of velocity template engine, other development tools can also be used. 以下对于velocity自定义标签进行举例说明。 For the velocity custom tags exemplified. [0032] velocity 自定义标签VelocityCompressTag[0033] public String parsejs (List<String>fileNames, String version)[0034] 该方法实现了,从前端vm页面中批量传入一个或多个js文件,服务端根据当前的配置的运行环境来决定是否进行压缩。 [0032] velocity custom label VelocityCompressTag [0033] public String parsejs (List <String> fileNames, String version) [0034] This method enables, from the front end vm page batch js pass one or more files, according to the server the current configuration of the operating environment to decide whether to compress. [0035] 参数说明:[0036] fileNames:传入的js相对路径[0037] version: js文件的列表的版本号[0038] public String inlinejs(String[]fileNames)[0039] 该方法实现将多个js文件的内容读取出来内联的html页面中,这样做的好处是便于开发人员在开发中进行调试[0040] 参数说明:[0041] fileNames:传为的js相对路径[0042] 合并压缩核心服务实现CompressService[0043] public String compress(HttpServletRequest request, int type)[0044] 该方法实现了对多个文件进行循环压缩及合并功能。 [0035] Parameters: [0036] fileNames: relative path incoming js [0037] version: js file list version number [0038] public String inlinejs (String [] fileNames) [0039] The method enables a plurality of js file to read out the contents of the inline html page, the benefits of doing so is easier for developers to debug [0040] parameters in development: [0041] fileNames: Biography as a relative path js [0042] the combined compression core service Implementation CompressService [0043] public String compress (HttpServletRequest request, int type) [0044] the method enables the compression of multiple files and merge cycle. [0045] 参数说明:[0046] request:HttpServletRequest 请求[0047] type:文件类型,I表示js, 2表示css[0048] public String getFiIeContent(HttpServletRequest request, StringfiIeName, int type)[0049] 该方法实现了对某一个文件的内容的读取。 [0045] Parameters: [0046] request: HttpServletRequest request [0047] type: file type, I represents js, 2 denotes css [0048] public String getFiIeContent (HttpServletRequest request, StringfiIeName, int type) [0049] The method enables the reading of the contents of a file. [0050] 参数说明:[0051] request:HttpServletRequest 请求[0052] fiIeName: js 或css 的文件路径[0053] type:文件类型,I表示js, 2表示css[0054] public static void setResponseHeaderCache (longadddays, HttpServletRequest request,HttpServIetResponse response,Stringencoding)[0055] 该方法实现缓存策略。 [0050] Parameters: [0051] request: HttpServletRequest request [0052] fiIeName: file path js or css the [0053] type: file type, I represents js, 2 denotes css [0054] public static void setResponseHeaderCache (longadddays, HttpServletRequest request, HttpServIetResponse response, Stringencoding) [0055] the method enables caching strategy. [0056] 参数说明:[0057] adddays:客户端的缓存秒数[0058] request:请求[0059] response:响应[0060] encoding:字符编码,默认为UTF-8[0061] 图2是根据本发明实施例的传输网络数据的装置的示意图。 [0056] Parameters: [0057] adddays: Cache seconds client [0058] request: a request [0059] response: Response [0060] encoding: character encoding, default is UTF-8 [0061] FIG. 2 is according to the invention a schematic view of a data transmission network apparatus of the embodiment. 如图2所示,传输网络数据的装置20主要包括第一接收模块201、第一发送模块202、第二接收模块203、以及第二发送模块204。 2, the network data transmission apparatus 20 mainly includes a first receiving module 201, a first transmitting module 202, a second receiving module 203, and a second transmitting module 204. 图2还示出了分布式缓存22以及服务器的文件系统23。 2 also illustrates a distributed cache server 22 and file system 23. [0062] 第一接收模块201用于接收终端的访问网络地址的请求;第一发送模块202用于向所述终端发送网页源代码,所述网页源代码中包含用于指定javascript文件和/或层叠样式表(CSS)文件的指令;第二接收模块203用于接收所述终端根据所述指令生成的请求信息;第二发送模块204用于将压缩文件提供给所述终端,所述压缩文件中包含有所述指令指定的javascript文件和/或CSS文件。 [0062] a first receiving module 201 requests for access to the network address of the receiving terminal; transmitting module 202 for transmitting a first page source code to the terminal, the web page source code includes a javascript file is used to specify and / or instruction Cascading style Sheets (CSS) file; a second receiving module 203 is configured to receive the request information terminal according to the instructions generated; a second module 204 for transmitting the compressed file to the terminal, the compressed file It contains the instructions specified javascript file and / or a CSS file. [0063] 第二发送模块204还可用于:从分布式缓存22中获取压缩文件然后发送给所述终端;在分布式缓存22中不存在所述压缩文件的情况下,从文件系统23中获取所述指令指定的javascript文件和/或CSS文件然后压缩得到所述压缩文件,再将该压缩文件发送给所述终端并且保存在分布式缓存22中。 [0063] The second sending module 204 may also be used: the terminal is then transmitted to the distributed cache 22 acquires from the compressed file; acquired from the file system 23 in the case of a distributed cache 22 in the compressed file does not exist the instructions specified javascript file and / or CSS file is then compressed to obtain the compressed file, and then transmits the compressed file to the terminal and stored in the distributed cache 22. [0064] 第二发送模块204还可用于:设置有效时长;从所述压缩文件被保存在分布式缓存22中起经过所述有效时长后,将所述压缩文件从分布式缓存22中删除。 [0064] The second sending module 204 may also be configured to: set the valid duration; is stored in the effective length of said distributed cache 22 since elapsed from the compressed file, the compressed file is deleted from the distributed cache 22. [0065] 第二发送模块204还可用于:将从文件系统中获取的所述指令指定的javascript文件和/或CSS文件进行压缩处理,并且根据获取的javascript文件和/或CSS文件的文件名得到唯一对应于获取的javascript文件和/或CSS文件的字段,将该字段作为所述压缩处理得到的压缩文件的文件名。 [0065] The second sending module 204 may also be used: the instruction acquired from the file system designated javascript file and / or CSS file compression processing, and obtain the file name acquired javascript file and / or CSS file field corresponding to the acquired unique javascript file and / or the CSS file, the file name of the compressed file field as the compression processing obtained. [0066] 根据本发明实施例的技术方案,服务器响应于终端的访问网络地址的请求,向终端发送网页源代码,该网页源代码中包含用于指定javascript文件和/或层叠样式表(CSS)文件的指令;然后服务器响应于该终端根据上述指令生成的请求信息,将压缩文件提供给该终端,该压缩文件中包含有上述指令指定的javascript文件和/或CSS文件,从而在网页中事先指定要提供的javascript文件和/或CSS文件,无需网页开发人员手动制作压缩文件,而是在网页被浏览时临时由服务器制作压缩文件,并且在修改页面、改变要提供的javascript文件和/或CSS文件的情况下,只需修改网页代码,仍无需网页开发人员手动制作压缩文件,提高了网页开发、修改和测试的效率;并且减小了人工参与的程度,于是减小了页面的出错率。 [0066] According to the embodiment of the present invention, the server response to a request to access the network address of the terminal, the terminal transmits page source code, the source code comprising the page for specifying a javascript file and / or Cascading Style Sheets (CSS) instruction file; and the server in response to the terminal according to the request information of the generated command, the compressed file to the terminal, the compressed file contains the command specified javascript file and / or CSS files, to specify in advance in the page javascript files and / or CSS file to be provided without web developers to make the compressed file manually, but temporary zip file from the server made when the page was viewed, and modify the page, change the javascript files to be provided and / or CSS files under the circumstances, simply modify the page code, web developers still do not need to manually make a compressed file, improve the efficiency of web development, modification and testing; and reduces the degree of human intervention, thus reducing the error rate of the page. 并且根据本发明实施例的技术方案,优先从读写速度较快的缓存中读取现成的压缩文件,如果没有该压缩文件再临时读取javascript文件和/或CSS文件并压缩得到压缩文件,并且将得到的压缩文件保存到缓存中,这样,只有当页面被第一次浏览时需要临时生成压缩文件,使页面的呈现速度受到影响以外,页面被再次浏览时因为缓存中已经保存了压缩文件所以呈现速度较快,提高了页面上线运行的效率。 According to the embodiment and the embodiment of the present invention, the priority is read from the compressed file ready faster read and write cache, if not read the temporary file and then compressed javascript file and / or CSS file and the compressed file is compressed, and save the compressed file will get to the cache, so that only when the page is first necessary to temporarily generate a compressed file browser, the page rendering speed is affected outside the browser when the page is saved again because the cache has been so compressed file rendering faster, improve the efficiency of the line to run the page. [0067] 以上结合具体实施例描述了本发明的基本原理,但是,需要指出的是,对本领域的普通技术人员而言,能够理解本发明的方法和设备的全部或者任何步骤或者部件,可以在任何计算装置(包括处理器、存储介质等)或者计算装置的网络中,以硬件、固件、软件或者它们的组合加以实现,这是本领域普通技术人员在阅读了本发明的说明的情况下运用他们的基本编程技能就能实现的。 [0067] with reference to specific embodiments describe the basic principles of the invention, however, to be noted that those of ordinary skill in the art can understand that all the methods and apparatus of the present invention or any steps or components, may be any computing device (including a processor, a storage medium etc.) or a network computing device, hardware, firmware, software, or a combination thereof be implemented, which those of ordinary skill in the art to use in reading the description of the present invention their basic programming skills will be able to achieve. [0068] 因此,本发明的目的还可以通过在任何计算装置上运行一个程序或者一组程序来实现。 [0068] Accordingly, an object of the present invention may also be achieved by running a program on any computing device or a set of programs. 所述计算装置可以是公知的通用装置。 The device may be a general purpose computing device known. 因此,本发明的目的也可以仅仅通过提供包含实现所述方法或者装置的程序代码的程序产品来实现。 Accordingly, an object of the present invention may also be provided only by comprising program code means implementing the method or program products. 也就是说,这样的程序产品也构成本发明,并且存储有这样的程序产品的存储介质也构成本发明。 That is, such a program product also forms the present invention, and a storage medium storing such a program product also forms the present invention. 显然,所述存储介质可以是任何公知的存储介质或者将来开发出的任何存储介质。 Obviously, the storage medium may be any known storage medium, or any storage medium developed in the future. [0069] 还需要指出的是,在本发明的装置和方法中,显然,各部件或各步骤是可以分解和/或重新组合的。 [0069] also to be noted that, in the apparatus and method of the present invention, obviously, the parts or steps may be decomposed and / or recombined. 这些分解和/或重新组合应视为本发明的等效方案。 These decomposition and / or recombination of the present invention should be considered equivalents. 并且,执行上述系列处理的步骤可以自然地按照说明的顺序按时间顺序执行,但是并不需要一定按照时间顺序执行。 Further, the above-described series of processing steps can naturally be performed chronologically in order of description but need not necessarily be performed chronologically. 某些步骤可以并行或彼此独立地执行。 Some steps may be performed in parallel or independently of one another. [0070] 上述具体实施方式,并不构成对本发明保护范围的限制。 [0070] The specific embodiments do not limit the scope of the present invention. 本领域技术人员应该明白的是,取决于设计要求和其他因素,可以发生各种各样的修改、组合、子组合和替代。 Those skilled in the art would understand that, depending on design requirements and other factors that can occur various modifications, combinations, sub-combinations and alternatives. 任何在本发明的精神和原则之内所作的修改、等同替换和改进等,均应包含在本发明保护范围之内。 Any modifications within the spirit and principle of the present invention, equivalent substitutions and improvements should be included within the scope of the present invention.

Claims (8)

  1. 1.一种传输网络数据的方法,其特征在于,包括: 服务器响应于终端的访问网络地址的请求,向所述终端发送网页源代码,所述网页源代码中包含用于指定javascript文件和/或层叠样式表(CSS)文件的指令; 服务器响应于所述终端根据所述指令生成的请求信息,将压缩文件提供给所述终端,所述压缩文件中包含有所述指令指定的javascript文件和/或CSS文件。 A network data transmission method, comprising: a server in response to a request to access the network address of the terminal, and transmits to the terminal page source code, the source code of the web page contains a javascript file and specify / or instructions Cascading style Sheets (CSS) file; server terminal in response to the request according to the instruction information generated by the compressed file to the terminal, the compressed javascript file contains the instructions and designated / or CSS files.
  2. 2.根据权利要求1所述的方法,其特征在于,将压缩文件提供给所述终端的步骤包括: 从分布式缓存中获取压缩文件然后发送给所述终端; 在所述分布式缓存中不存在所述压缩文件的情况下,从文件系统中获取所述指令指定的javascript文件和/或CSS文件然后压缩得到所述压缩文件,再将该压缩文件发送给所述终端并且保存在所述分布式缓存中。 2. The method according to claim 1, wherein the compressed file to said terminal comprises the step of: obtaining files from the distributed cache is then sent to the terminal; not in the distributed cache the presence of the compressed file, obtaining the instructions from a file system specified javascript file and / or CSS file is then compressed to obtain the compressed file, and then transmits the compressed file to the terminal and stored in said profile style cache.
  3. 3.根据权利要求2所述的方法,其特征在于,压缩得到所述压缩文件的步骤之后,还包括: 设置有效时长; 从所述压缩文件被保存在所述分布式缓存中起经过所述有效时长后,将所述压缩文件从所述分布式缓存中删除。 3. The method according to claim 2, characterized in that, after the step of compressing the compressed file obtained, further comprising: setting a valid duration; from the compressed file is stored in the distributed cache from passing through the after the effective length of time, the compressed file is deleted from the distributed cache.
  4. 4.根据权利要求2或3所述的方法,其特征在于,压缩得到所述压缩文件的步骤包括: 将从文件系统中获取的所述指令指定的javascript文件和/或CSS文件进行压缩处理,并且根据获取的javascript文件和/或CSS文件的文件名得到唯一对应于获取的javascript文件和/或CSS文件的字段,将该字段作为所述压缩处理得到的压缩文件的文件名。 A method according to claim 2 or claim 3, wherein said compression to obtain a compressed file comprises: the instruction acquired from the file system designated javascript file and / or CSS file compression process, and the resulting field corresponding to the acquired unique javascript file and / or CSS file according to the file name acquired javascript file and / or a CSS file, and the file name field as the compression process of the compressed file obtained.
  5. 5.一种传输网络数据的装置,其特征在于,包括: 第一接收模块,用于接收终端的访问网络地址的请求; 第一发送模块,用于向所述终端发送网页源代码,所述网页源代码中包含用于指定javascript文件和/或层叠样式表(CSS)文件的指令; 第二接收模块,用于接收所述终端根据所述指令生成的请求信息; 第二发送模块,用于将压缩文件提供给所述终端,所述压缩文件中包含有所述指令指定的javascript文件和/或CSS文件。 An apparatus for data transmission network, characterized by comprising: a first receiving module, for requesting access to the network address of the receiving terminal; a first sending module, configured to send a page source code to the terminal, the page source code contains a command or specify a javascript file and / Cascading style Sheets (CSS) file; a second receiving module configured to receive the request information generated by the terminal according to the instruction; second sending module, configured to the terminal provided to the compressed file, the compressed javascript file and / or CSS file contains the file specified by the instruction.
  6. 6.根据权利要求5所述的装置,其特征在于,所述第二发送模块还用于: 从分布式缓存中获取压缩文件然后发送给所述终端; 在所述分布式缓存中不存在所述压缩文件的情况下,从文件系统中获取所述指令指定的javascript文件和/或CSS文件然后压缩得到所述压缩文件,再将该压缩文件发送给所述终端并且保存在所述分布式缓存中。 6. The apparatus as claimed in claim 5, wherein said second sending module is further configured to: obtain files from the distributed cache is then sent to the terminal; are not present in the distributed cache in the case referred to the compressed file, obtaining the instructions from a file system specified javascript file and / or CSS file is then compressed to obtain the compressed file, and then transmits the compressed file to the terminal and stored in the distributed buffer in.
  7. 7.根据权利要求5所述的装置,其特征在于,所述第二发送模块还用于: 设置有效时长; 从所述压缩文件被保存在所述分布式缓存中起经过所述有效时长后,将所述压缩文件从所述分布式缓存中删除。 7. The apparatus as claimed in claim 5, wherein said second sending module is further configured to: set the valid duration; from the compressed file is stored after the valid duration elapsed since the distributed cache , the compressed file is deleted from the distributed cache.
  8. 8.根据权利要求6或7所述的装置,其特征在于,所述第二发送模块还用于: 将从文件系统中获取的所述指令指定的javascript文件和/或CSS文件进行压缩处理,并且根据获取的javascript文件和/或CSS文件的文件名得到唯一对应于获取的javascript文件和/或CSS文件的字段,将该字段作为所述压缩处理得到的压缩文件的文件名。 8. The apparatus of claim 6 or claim 7, wherein said second sending module is further configured to: the instruction acquired from the file system designated javascript file and / or CSS file compression process, and the resulting field corresponding to the acquired unique javascript file and / or CSS file according to the file name acquired javascript file and / or a CSS file, and the file name field as the compression process of the compressed file obtained.
CN 201310040161 2013-02-01 2013-02-01 A method and apparatus for data transmission network CN103139298B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201310040161 CN103139298B (en) 2013-02-01 2013-02-01 A method and apparatus for data transmission network

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201310040161 CN103139298B (en) 2013-02-01 2013-02-01 A method and apparatus for data transmission network

Publications (2)

Publication Number Publication Date
CN103139298A true true CN103139298A (en) 2013-06-05
CN103139298B CN103139298B (en) 2017-04-12

Family

ID=48498595

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201310040161 CN103139298B (en) 2013-02-01 2013-02-01 A method and apparatus for data transmission network

Country Status (1)

Country Link
CN (1) CN103139298B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283947A (en) * 2014-09-28 2015-01-14 深圳市中科无软件有限公司 Java script dynamic consolidated server and work process thereof
WO2017041538A1 (en) * 2015-09-09 2017-03-16 深圳Tcl数字技术有限公司 Terminal user interface controlled display method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1988576A (en) * 2006-12-18 2007-06-27 韩壮 Method for realizing mobile terminal dynamic cache memory multimedia interactive advertisement
CN101446960A (en) * 2008-12-30 2009-06-03 深圳市茁壮网络技术有限公司 Method for browsing web page at digital television terminal and browser thereof
CN102081633A (en) * 2009-11-27 2011-06-01 阿里巴巴集团控股有限公司 JavaScript file management method, device and system
CN102096712A (en) * 2011-01-28 2011-06-15 深圳市五巨科技有限公司 Method and device for cache-control of mobile terminal
US20120159430A1 (en) * 2010-12-15 2012-06-21 Microsoft Corporation Extensible template pipeline for web applications

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1988576A (en) * 2006-12-18 2007-06-27 韩壮 Method for realizing mobile terminal dynamic cache memory multimedia interactive advertisement
CN101446960A (en) * 2008-12-30 2009-06-03 深圳市茁壮网络技术有限公司 Method for browsing web page at digital television terminal and browser thereof
CN102081633A (en) * 2009-11-27 2011-06-01 阿里巴巴集团控股有限公司 JavaScript file management method, device and system
US20120159430A1 (en) * 2010-12-15 2012-06-21 Microsoft Corporation Extensible template pipeline for web applications
CN102096712A (en) * 2011-01-28 2011-06-15 深圳市五巨科技有限公司 Method and device for cache-control of mobile terminal

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
宁海荣: "《上海复旦大学硕士学位论文》", 31 August 2012, article "基于HttpModule的网站页面性能动态优化系统构建" *
赵丙秀: "Js合并工具在互联网软件开发中的应用", 《电脑知识与技术》, no. 35, 31 December 2010 (2010-12-31) *
马健: "用javascript获取网页中的JS、CSS、Flash等文件", 《JAVASCRIPT教程,HTTP://WWW.EDUCITY.CN/JAVA/668612.HTML》, 28 September 2005 (2005-09-28) *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283947A (en) * 2014-09-28 2015-01-14 深圳市中科无软件有限公司 Java script dynamic consolidated server and work process thereof
WO2017041538A1 (en) * 2015-09-09 2017-03-16 深圳Tcl数字技术有限公司 Terminal user interface controlled display method and device

Also Published As

Publication number Publication date Type
CN103139298B (en) 2017-04-12 grant

Similar Documents

Publication Publication Date Title
US9075893B1 (en) Providing files with cacheable portions
US20090100228A1 (en) Methods and systems for implementing a cache model in a prefetching system
US20110314091A1 (en) Method and system for automated analysis and transformation of web pages
US20090083714A1 (en) Remote monitoring of local behavior of network applications
US20090019105A1 (en) Methods and systems for java script parsing
US20130246906A1 (en) System and method providing a binary representation of a web page
US20100312821A1 (en) Web Page Optimization
US20120079057A1 (en) Acceleration and optimization of web pages access by changing the order of resource loading
US20120084346A1 (en) Page Loading Optimization Using Page-Maintained Cache
US20090024982A1 (en) Apparatus, system, and method for archiving small objects to improve the loading time of a web page
US20130124621A1 (en) Methods and systems for implementing a cache model in a prefetching system
US8527860B1 (en) System and method for exposing the dynamic web server-side
CN103379127A (en) Data interaction method and apparatus between server and client
US8639743B1 (en) System and method for on-the-fly rewriting of JavaScript
US8977653B1 (en) Modifying web pages to reduce retrieval latency
US7870482B2 (en) Web browser extension for simplified utilization of web services
US7694282B2 (en) Mapping breakpoints between web based documents
CN101996194A (en) On-line browsing method and system of electronic file
CN103377127A (en) Development testing system, testing method and device for webpage product
US20110219355A1 (en) Business rules management system
US20110161840A1 (en) Performance of template based javascript widgets
US20130086138A1 (en) Implementing a java method
CN102779128A (en) Method and device for offline running of HTML5 (hypertext markup language 5) application program in mobile terminal
CN101770502A (en) Scripting method, device and embedded browser
CN102737067A (en) Method and system for outputting webpage

Legal Events

Date Code Title Description
C06 Publication
C10 Entry into substantive examination
GR01