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

Method for transmitting network data and device Download PDF

Info

Publication number
CN103139298B
CN103139298B CN201310040161.9A CN201310040161A CN103139298B CN 103139298 B CN103139298 B CN 103139298B CN 201310040161 A CN201310040161 A CN 201310040161A CN 103139298 B CN103139298 B CN 103139298B
Authority
CN
China
Prior art keywords
files
css
file
terminal
compressed file
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201310040161.9A
Other languages
Chinese (zh)
Other versions
CN103139298A (en
Inventor
赵宏波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
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
Application filed by Beijing Jingdong Century Trading Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201310040161.9A priority Critical patent/CN103139298B/en
Publication of CN103139298A publication Critical patent/CN103139298A/en
Application granted granted Critical
Publication of CN103139298B publication Critical patent/CN103139298B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

A kind of method and apparatus of transmitting network data
Technical field
The present invention relates to a kind of method and apparatus of transmitting network data.
Background technology
Based on B/S frameworks software development process in, it is often necessary to use substantial amounts of javascript frameworks, control, Self-defining javascript codes and substantial amounts of cascading style list file (CSS), in order to improve the terminal i.e. download of browser Speed, during page development, developer is by the multiple javascript and/or css files used in webpage by the Tripartite's tool compresses are merged into a compressed file and are got off corresponding to the Page-saving, after such page is reached the standard grade, browse In analyzing web page source code and when sending request, server obtains above-mentioned compressed file and is provided to browser device.
If javascript the and/or css files that web page contents are changed and relate to use, developer's weight The above-mentioned compressed file of new production, and the accordingly filename of the other guide such as compressed file in the modification page.
The page from developing to testing, change up to the renewal in on-line running, content of pages generally will be changed repeatedly, be pressed According to existing above-mentioned way, need developer repeatedly to make compressed file, cause inefficiency and error rate to increase.
The content of the invention
In view of this, the present invention provides a kind of method and apparatus of transmitting network data, it is possible to increase the page from exploitation to Test, modification are until the efficiency of the renewal in on-line running, and reduces the error rate of the page.
For achieving the above object, according to an aspect of the invention, there is provided a kind of method of transmitting network data.
The method of the transmitting network data of the present invention includes:Server in response to terminal access the network address request, Web page source code is sent to the terminal, is included for specifying javascript files and cascading style in the web page source code The instruction of table (CSS) file, the instruction includes the file path of the javascript files and CSS files;The webpage It is the webpage during page development;The solicited message that server is generated in response to the terminal according to the instruction, from file The javascript files and CSS files are read in system, then compressed file the terminal, the compression text is supplied to into Include the javascript files specified and CSS files in part.
Alternatively, after the step of compression obtains the compressed file, also include:Effective time is set;From the compression File is stored in distributed caching and rises after the effective time, by the compressed file from the distributed caching Delete.
Alternatively, the step of compression obtains the compressed file includes:The instruction obtained from file system is referred to Fixed javascript files and CSS files is compressed process, and according to the javascript files and CSS files for obtaining Filename obtain being uniquely corresponding to the field of the javascript files and CSS files for obtaining, using the field as the pressure Contracting processes the filename of the compressed file for obtaining.
According to a further aspect in the invention, there is provided a kind of device of transmitting network data.
The device of the transmitting network data of the present invention is arranged in the server, and the device includes:First receiver module, is used for The request of the access network address of receiving terminal;First sending module, for sending web page source code, the net to the terminal The instruction for specifying javascript files and CSS (CSS) file is included in page source code, the instruction includes The file path of the javascript files and CSS files;The webpage is the webpage during page development;Second receives Module, for receiving the solicited message that the terminal is generated according to the instruction;Second sending module, for from file system The javascript files and CSS files are read, then compressed file the terminal is supplied to into, is wrapped in the compressed file Containing the javascript files specified and CSS files.
Alternatively, second sending module is additionally operable to:Effective time is set;Distribution is stored in from the compressed file Rise after the effective time in formula caching, the compressed file is deleted from the distributed caching.
Alternatively, second sending module is additionally operable to:The instruction obtained from file system is specified Javascript files and CSS files are compressed process, and according to the text of the javascript files and CSS files for obtaining Part name obtains being uniquely corresponding to the field of the javascript files and CSS files for obtaining, using the field as at the compression The filename of the compressed file that reason is obtained.
Technology according to the present invention scheme, server sends in response to the request of the access network address of terminal to terminal Web page source code, includes the finger for specifying javascript files and CSS (CSS) file in the web page source code Order;Then the solicited message that server is generated in response to the terminal according to above-mentioned instruction, by compressed file the terminal is supplied to, should Include javascript files and CSS files that above-mentioned instruction is specified in compressed file, will so as to specify in advance in webpage The javascript files and CSS files of offer, without the need for webpage development personnel compressed file is made manually, but clear in webpage Temporarily compressed file made by server when looking at, and the javascript files to be provided in the modification page, change and CSS are literary In the case of part, only web page code need to be changed, still make compressed file manually without the need for webpage development personnel, be improve webpage and open The efficiency sent out, change and test;And the degree of artificial participation is reduced, the error rate of the page is then reduced.And according to The technical scheme of the embodiment of the present invention, reads ready-made compressed file in preferentially caching faster from read or write speed, if do not had The compressed file reads again javascript files and CSS files and compresses and obtains compressed file temporarily, and by the pressure for obtaining Contracting file is saved in caching, so, interim generation compressed file is needed only when the page is browsed for the first time, makes the page Beyond presentation speed is affected, because having saved compressed file presentation speed in caching when the page is browsed again Comparatively fast, improve the efficiency of page on-line running.
Description of the drawings
Accompanying drawing does not constitute inappropriate limitation of the present invention for more fully understanding the present invention.Wherein:
Fig. 1 is the schematic diagram of the basic step of the method for transmitting network data according to embodiments of the present invention;
Fig. 2 is the schematic diagram of the device of transmitting network data according to embodiments of the present invention.
Specific embodiment
The one exemplary embodiment of the present invention is explained below in conjunction with accompanying drawing, including the various of the embodiment of the present invention They should be thought only exemplary by details to help understanding.Therefore, those of ordinary skill in the art should recognize Arrive, various changes and modifications can be made to the embodiments described herein, without departing from scope and spirit of the present invention.Together Sample, for clarity and conciseness, eliminates the description to known function and structure in description below.
Fig. 1 is the schematic diagram of the basic step of the method for transmitting network data according to embodiments of the present invention.Such as Fig. 1 institutes Show, the method for the transmitting network data of the embodiment of the present invention mainly includes steps S11 to step S14.
Step S11:Terminal to server sends the request for accessing the network address.
Step S12:Server to terminal sends web page source code.In this step, as to the request in step S11 Web page source code is sent to terminal by response, server.In web page source code comprising for specify javascript files and/or The instruction of CSS files.
Step S13:Terminal analyzing web page source code and to server send solicited message.In this step, terminal parsing The web page source code for receiving, after the instruction described in step S12 is resolved to, generates solicited message to ask according to the instruction Obtain corresponding javascript files and/or CSS files.
Step S14:Compressed file is supplied to terminal by server.In this step, as to the request letter in step S13 The response of breath, server has two ways to provide the terminal with compressed file.If having had phase in the distributed caching of server The compressed file answered, then directly by the compressed file be sent to terminal;Read otherwise from file system that terminal is asked, real It is also each javascript file and/or CSS files of instruction in step S12 on border, then by these files Compression, obtains above-mentioned corresponding compressed file, then the compressed file is sent to into terminal.
From above-mentioned steps as can be seen that in advance the specified javascript files to be provided and/or CSS are literary in webpage Part, just makes manually compressed file without the need for webpage development personnel, but is made by server temporarily when webpage is browsed and compressed File, and in the case of the javascript files and/or CSS files that the modification page, change to be provided, only need to change net Page code, still makes manually compressed file without the need for webpage development personnel, improves webpage development, modification and the efficiency tested;And And the artificial degree for participating in is reduced, then reduce the error rate of the page.
And can also be seen that from above-mentioned steps due to being the interim making compressed file in navigation process, so right Page when browsing has a certain impact in the presentation speed of terminal, so in step S14, it is preferentially very fast from read or write speed Caching in read ready-made compressed file, if the compressed file does not read again javascript files and/or CSS temporarily File and compression obtains compressed file, and the compressed file for obtaining is saved in caching.So, only when the page is by first It is secondary need when browsing it is interim generate compressed file, beyond making the presentation speed of the page be affected, when the page is browsed again because To have saved compressed file in caching so presentation speed comparatively fast, improves the efficiency of page on-line running.
It should be noted that in step s 13, common browser all can be searched first from local cache to be needed Javascript files and/or CSS files, the sending to server in execution step S13 again in the case where not finding Solicited message.
It is literary with these javascript files of compression and/or CSS in order to ensure javascript files and/or CSS files Unique correspondence between compressed file obtained by part, can be after compression be completed, according to the javascript for being compressed The filename of file and/or CSS files obtains being uniquely corresponding to the field of these javascript files and/or CSS files, example Hash calculating is carried out after such as the filename of these javascript files and/or CSS files can be joined end to end, will be obtained Hashed value as compressed file filename.Correspondingly, server is received in step s 13 after solicited message, according to request The filename of javascript files and/or CSS files in information, carry out same way processes dissipating for such as same way Column count is so as to obtaining the filename of corresponding compressed file.
Even if because the page is also possible to be further modified during on-line running, it is possible to preserving in the buffer Compressed file effective time is set, generating compressed file and starting timing when being stored in caching, when above-mentioned effective The compressed file is just removed from the cache after length.
According to the such scheme of the present embodiment, in the implementation, can be unified as end from velocity customized labels Method of calling, merge compression engine can adopt yuicompressor, to compression merge after file content can adopt Memcahced is used as caching, while taking over seamlessly for Cache Framework can be carried out by realizing different cache interfaces.Certainly It is not limited to when the page is developed using velocity template engines, other developing instruments can also be used.Below for Velocity customized labels are illustrated.
Velocity customized label VelocityCompressTag
public String parseJs(List<String>fileNames,String version)
The method achieve, incoming one or more js files of batch from the vm pages of front end, service end is according to current The running environment of configuration is deciding whether to be compressed.
Parameter declaration:
fileNames:Incoming js relative paths
version:The version number of the list of js files
public String inlineJs(String[]fileNames)
The method is realized the content of multiple js files being read out in the inline html pages, advantage of this is that just Debugged in developer is under development
Parameter declaration:
fileNames:Pass the js relative paths for being
Merge compressed core service and realize CompressService
public String compress(HttpServletRequest request,int type)
The method achieve and multiple files are circulated with compression and pooling function.
Parameter declaration:
request:HttpServletRequest is asked
type:File type, 1 represents js, and 2 represent css
public String getFileContent(HttpServletRequest request,String fileName,int type)
The method achieve the reading of the content to some file.
Parameter declaration:
request:HttpServletRequest is asked
fileName:The file path of js or css
type:File type, 1 represents js, and 2 represent css
public static void setResponseHeaderCache(long adddays, HttpServletRequest request,HttpServletResponse response,String encoding)
The method realizes cache policy.
Parameter declaration:
adddays:The caching number of seconds of client
request:Request
response:Response
encoding:Character code, is defaulted as UTF-8
Fig. 2 is the schematic diagram of the device of transmitting network data according to embodiments of the present invention.As shown in Fig. 2 transmission network The device 20 of data mainly includes the first receiver module 201, the first sending module 202, the second receiver module 203 and second Sending module 204.Fig. 2 also show the file system 23 of distributed caching 22 and server.
First receiver module 201 is used for the request of the access network address of receiving terminal;First sending module 202 be used for The terminal sends web page source code, includes in the web page source code for specifying javascript files and/or stacking sample The instruction of formula table (CSS) file;Second receiver module 203 is used to receive the request letter that the terminal is generated according to the instruction Breath;Second sending module 204 is used to for compressed file to be supplied to the terminal, and described finger is included in the compressed file Fixed javascript files and/or CSS files.
Second sending module 204 can be additionally used in:Compressed file is obtained from distributed caching 22 and is then sent to the end End;In the case of there is no the compressed file in distributed caching 22, the instruction is obtained from file system 23 and is specified Javascript files and/or CSS files and then compress and obtain the compressed file, then the compressed file is sent to described Terminal and it is stored in distributed caching 22.
Second sending module 204 can be additionally used in:Effective time is set;Distributed caching is stored in from the compressed file Rise in 22 after the effective time, the compressed file is deleted from distributed caching 22.
Second sending module 204 can be additionally used in:The javascript that the instruction obtained from file system is specified File and/or CSS files are compressed process, and according to the filename of the javascript files and/or CSS files for obtaining Obtain being uniquely corresponding to the field of the javascript files and/or CSS files for obtaining, process the field as the compression The filename of the compressed file for obtaining.
Technical scheme according to embodiments of the present invention, server in response to terminal access the network address request, to end End sends web page source code, includes for specifying javascript files and/or CSS (CSS) in the web page source code The instruction of file;Then the solicited message that server is generated in response to the terminal according to above-mentioned instruction, compressed file is supplied to The terminal, includes javascript files and/or CSS files that above-mentioned instruction is specified, so as in webpage in the compressed file In javascript files and/or the CSS files to be provided is provided in advance, make compression text manually without the need for webpage development personnel Part, but temporarily compressed file made by server when webpage is browsed, and to be provided in the modification page, change In the case of javascript files and/or CSS files, only web page code need to be changed, still be made manually without the need for webpage development personnel Make compressed file, improve webpage development, modification and the efficiency tested;And the degree of artificial participation is reduced, is then reduced The error rate of the page.And technical scheme according to embodiments of the present invention, reads in preferentially caching faster from read or write speed Ready-made compressed file, if the compressed file does not read again javascript files and/or CSS files and compresses temporarily To compressed file, and the compressed file for obtaining is saved in caching, so, the needs only when the page is browsed for the first time It is interim to generate compressed file, beyond making the presentation speed of the page be affected, because when the page is browsed again in caching Compressed file is saved so presentation speed comparatively fast, improves the efficiency of page on-line running.
The ultimate principle of the present invention is described above in association with specific embodiment, however, it is desirable to, it is noted that to this area For those of ordinary skill, it is to be understood that whole either any step or part of the method for the present invention and equipment, Ke Yi In any computing device (including processor, storage medium etc.) or the network of computing device, with hardware, firmware, software or Combinations thereof is realized that this is that those of ordinary skill in the art use them in the case where the explanation of the present invention has been read Basic programming skill can be achieved with.
Therefore, the purpose of the present invention can also by a program or batch processing are run on any computing device come Realize.The computing device can be known fexible unit.Therefore, the purpose of the present invention can also be included only by offer Realize the program product of program code of methods described or device realizing.That is, such program product is also constituted The present invention, and the storage medium of such program product that is stored with also constitutes the present invention.Obviously, the storage medium can be Any known storage medium or any storage medium developed in the future.
It may also be noted that in apparatus and method of the present invention, it is clear that each part or each step can be to decompose And/or reconfigure.These decompose and/or reconfigure should be regarded as the present invention equivalents.Also, perform above-mentioned series The step of process can order naturally following the instructions perform in chronological order, but and need not necessarily sequentially in time Perform.Some steps can be performed parallel or independently of one another.
Above-mentioned specific embodiment, does not constitute limiting the scope of the invention.Those skilled in the art should be bright It is white, depending on design requirement and other factors, various modifications, combination, sub-portfolio and replacement can occur.It is any Modification, equivalent and improvement for being made within the spirit and principles in the present invention etc., should be included in the scope of the present invention Within.

Claims (6)

1. a kind of method of transmitting network data, it is characterised in that include:
Server sends web page source code, the web page source in response to the request of the access network address of terminal to the terminal Comprising being used to specify the instruction of javascript files and CSS (CSS) file in code, the instruction is including described The file path of javascript files and CSS files;The webpage is the webpage during page development;
The solicited message that server is generated in response to the terminal according to the instruction, reads described from file system Javascript files and CSS files, are then supplied to the terminal by compressed file, include described in the compressed file The javascript files specified and CSS files.
2. method according to claim 1, it is characterised in that after the step of compression obtains the compressed file, also wrap Include:
Effective time is set;
From the compressed file is stored in distributed caching after the effective time, by the compressed file from institute State in distributed caching and delete.
3. method according to claim 1, it is characterised in that the step of compression obtains the compressed file includes:
The javascript files and CSS files that the instruction obtained from file system is specified is compressed process, and And the javascript files for obtaining being uniquely corresponding to obtain according to the filename of the javascript files and CSS files that obtain With the field of CSS files, the field is processed into the filename of the compressed file for obtaining as the compression.
4. a kind of device of transmitting network data, it is characterised in that arrange in the server, the device includes:
First receiver module, for the request of the access network address of receiving terminal;
First sending module, for sending web page source code to the terminal, includes for specifying in the web page source code The instruction of javascript files and CSS (CSS) file, the instruction includes the javascript files and CSS The file path of file;The webpage is the webpage during page development;
Second receiver module, for receiving the solicited message that the terminal is generated according to the instruction;
Second sending module, for reading the javascript files and CSS files from file system, then will compression text Part is supplied to the terminal, and the javascript files specified and CSS files are included in the compressed file.
5. device according to claim 4, it is characterised in that second sending module is additionally operable to:
Effective time is set;
From the compressed file is stored in distributed caching after the effective time, by the compressed file from institute State in distributed caching and delete.
6. device according to claim 4, it is characterised in that second sending module is additionally operable to:
The javascript files and CSS files that the instruction obtained from file system is specified is compressed process, and And the javascript files for obtaining being uniquely corresponding to obtain according to the filename of the javascript files and CSS files that obtain With the field of CSS files, the field is processed into the filename of the compressed file for obtaining as the compression.
CN201310040161.9A 2013-02-01 2013-02-01 Method for transmitting network data and device Active CN103139298B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310040161.9A CN103139298B (en) 2013-02-01 2013-02-01 Method for transmitting network data and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310040161.9A CN103139298B (en) 2013-02-01 2013-02-01 Method for transmitting network data and device

Publications (2)

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

Family

ID=48498595

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310040161.9A Active CN103139298B (en) 2013-02-01 2013-02-01 Method for transmitting network data and device

Country Status (1)

Country Link
CN (1) CN103139298B (en)

Families Citing this family (4)

* 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
CN106209925B (en) * 2015-04-29 2019-07-26 阿里巴巴集团控股有限公司 Page loading method, client and system
CN105159677A (en) * 2015-09-09 2015-12-16 深圳Tcl数字技术有限公司 Controlled display method of terminal user interface and controlled display device of terminal user interface
CN107463563B (en) * 2016-06-02 2020-12-08 腾讯科技(深圳)有限公司 Information service processing method and device of browser

Citations (3)

* 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
CN102096712A (en) * 2011-01-28 2011-06-15 深圳市五巨科技有限公司 Method and device for cache-control of mobile terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081633A (en) * 2009-11-27 2011-06-01 阿里巴巴集团控股有限公司 JavaScript file management method, device and system
US9864611B2 (en) * 2010-12-15 2018-01-09 Microsoft Technology Licensing, Llc Extensible template pipeline for web applications

Patent Citations (3)

* 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
CN102096712A (en) * 2011-01-28 2011-06-15 深圳市五巨科技有限公司 Method and device for cache-control of mobile terminal

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Js合并工具在互联网软件开发中的应用;赵丙秀;《电脑知识与技术》;20101231(第35期);第1-3页 *
用javascript获取网页中的JS、CSS、Flash等文件;马健;《javascript教程,http://www.educity.cn/java/668612.html》;20050928;全文 *

Also Published As

Publication number Publication date
CN103139298A (en) 2013-06-05

Similar Documents

Publication Publication Date Title
CN107832277B (en) System and method for providing binary representation of web page
CN101635655B (en) Method, device and system for page performance test
CN103699410B (en) Method and device for updating application programs
CA2640025C (en) Methods and devices for post processing rendered web pages and handling requests of post processed web pages
JP6203374B2 (en) Web page style address integration
CN103078945B (en) To the method and system that browser crash data processes
CN110213113B (en) WEB configuration management method of base station and base station
CN110858172A (en) Automatic test code generation method and device
CN105095367B (en) A kind of acquisition method and device of client data
US9729672B2 (en) Collaborative editing
CN103139298B (en) Method for transmitting network data and device
CN113382083B (en) Webpage screenshot method and device
CN111010364A (en) System for offline object-based storage and simulation of REST responses
US10049089B2 (en) Methods for compressing web page menus and devices thereof
CN108536489B (en) Method, apparatus, and computer-readable storage medium for matching resource environments
CN112732572A (en) Service testing method, device and system, storage medium and electronic device
CN112416964A (en) Data processing method, device and system, computer equipment and computer readable storage medium
CN107526755B (en) Data processing method and device
CN104731869A (en) Page display method and device
US20150106691A1 (en) Generation of Combined Documents from Content and Layout Documents Based on Semantically Neutral Elements
CN109145236A (en) Page file processing method, apparatus and system
CN104361007B (en) The processing method of browser and its collection
CN106933569A (en) A kind of webpage method for refreshing and device
CN112632425B (en) Method, device, equipment and storage medium for generating offline resource file
US11392663B2 (en) Response based on browser engine

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant