CN111736926A - Method and system for using CDN acceleration service in Java Web program in low-intrusion mode - Google Patents

Method and system for using CDN acceleration service in Java Web program in low-intrusion mode Download PDF

Info

Publication number
CN111736926A
CN111736926A CN202010477535.3A CN202010477535A CN111736926A CN 111736926 A CN111736926 A CN 111736926A CN 202010477535 A CN202010477535 A CN 202010477535A CN 111736926 A CN111736926 A CN 111736926A
Authority
CN
China
Prior art keywords
cdn
link
cdn service
page
filter
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.)
Pending
Application number
CN202010477535.3A
Other languages
Chinese (zh)
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 Huibo Technology Co ltd
Original Assignee
Beijing Huibo Technology 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 Huibo Technology Co ltd filed Critical Beijing Huibo Technology Co ltd
Priority to CN202010477535.3A priority Critical patent/CN111736926A/en
Publication of CN111736926A publication Critical patent/CN111736926A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • G06F9/4451User profiles; Roaming
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention relates to a method and a system for using CDN acceleration service in a Java Web program in a low-intrusion mode. The method comprises the following steps: 1) after receiving an access request sent by a user side, the Java Web judges whether a system configuration switch starts the CDN or not, if the CDN is started, the step 2) is carried out, and if not, the original page is returned; 2) configuring a filter in a Java Web application program to enable a target page to use CDN service; and detecting whether a link of the resource file exists in the filter, and if so, replacing the link of the resource file with the CDN service link. The invention greatly simplifies the process of accessing the CDN service, can flexibly judge the access of the CDN and replace the CDN service domain name in actual use without rewriting all resource links.

Description

Method and system for using CDN acceleration service in Java Web program in low-intrusion mode
Technical Field
The invention belongs to the field of CDN acceleration service, and particularly relates to a method and a system for using CDN acceleration service in a Java Web program in a low-intrusion mode.
Background
In a Network, when a web page receives an access request, an accelerated path is usually provided to a visitor through a CDN (Content Delivery Network) so that a user can access the web page through a shorter path, where the CDN forms an intelligent virtual Network on the basis of the existing internet by placing node servers around the Network. The CDN system can redirect a request of a user to a service node closest to the user in real time according to the network traffic and comprehensive information such as connection of each node, a load condition, a distance to the user, and response time.
In the current IT industry, in most high concurrency scenarios, a CDN network needs to be relied on to speed up access of a user terminal, and how to quickly access a CDN service in a popular Java Web program is one of factors that determine when a user can obtain an optimal experience. One existing technique is to replace the resource links of pages in all Java Web programs with CDN service links. The technology of the disease needs to modify all page resource links, thereby causing the defects of low modification efficiency, easy error, difficult maintenance and the like.
In the prior art, when resource links of pages in a Java Web program are replaced by CDN service links, all page resource links need to be modified, and the method has the advantages of low modification efficiency, high error probability and low maintenance difficulty.
Disclosure of Invention
The technical scheme aims to provide a global switch in a low-intrusion mode to realize integrated CDN service.
The first aspect of the present invention provides a method for using CDN acceleration services in a Java Web program with low intrusion, including the following steps: 1) after receiving an access request sent by a user side, the Java Web judges whether a system configuration switch starts the CDN or not, if the CDN is started, the step 2) is carried out, and if not, the original page is returned; 2) configuring a filter in a Java Web application program to enable a target page to use CDN service; and detecting whether a link of the resource file exists in the filter, and if so, replacing the link of the resource file with the CDN service link.
The second aspect of the present invention provides a system for using CDN acceleration services in a Java Web program with low intrusion, including: a receiving unit, configured to receive an access request of a user side; a filtering unit, configured to filter out undesired requests and identify a target page that is desired to use the CDN service; and the replacing unit is used for replacing the link of the target page to the CDN service link.
The invention integrates CDN service by providing a global switch for judging whether the CDN is started or not in a low-intrusion mode with less code change when a frame or a module is removed. The invention greatly simplifies the process of accessing the CDN service, can flexibly judge the access of the CDN and replace the CDN service domain name in actual use without rewriting all resource links.
Drawings
Objects and features of the method and system of the present invention will be more readily understood by those skilled in the art after reading the various embodiments of the invention with reference to the accompanying drawings, which illustrate the following:
FIG. 1 is a flow chart of one embodiment of the method of the present invention.
Detailed Description
Embodiments of the method or system provided by the present invention are described below with reference to the drawings. Like reference numerals are used throughout the figures to describe like or similar parts. The various features disclosed herein can be used alone, or in varying combinations with each other and are not intended to limit the invention to the particular combinations described herein. Accordingly, the described embodiments are not intended to limit the scope of the claims.
The description may employ the phrases "in an embodiment," "in some embodiments," or "in other embodiments," which may each refer to one or more of the same or different embodiments, respectively, in accordance with the disclosure herein.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that an article or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such article or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in an article or device that comprises the element.
CDN is a new type of network construction, which is a network overlay layer optimized specifically for delivering broadband rich media over a traditional IP network. In a broad sense, the CDN represents a network service model based on quality and order. Briefly, the CDN is a strategically deployed overall system, which includes 4 elements of distributed storage, load balancing, network request redirection, and content Management, and the content Management and global network Traffic Management (Traffic Management) are the core of the CDN. By determining user proximity and server load, the CDN ensures that the content serves the user's request in an extremely efficient manner. In general, content services are implemented based on cache servers, also known as proxy caches (caches). The proxy cache is located at the edge of the network, just one Hop away from the user (Single Hop). Meanwhile, the proxy cache is a transparent mirror image of the content provider origin server (typically located in the CDN service provider's data center). Such an architecture enables CDN service providers to provide the best possible experience on behalf of their customers, i.e., content providers, to end users who cannot tolerate any delay in request response time.
The basic idea of the CDN is to avoid bottlenecks and links on the internet that may affect the data transmission speed and stability as much as possible, so that the content transmission is faster and more stable. By placing node servers at various positions of the network to form a layer of intelligent virtual network on the basis of the existing internet, the CDN system can redirect the request of a user to a service node closest to the user in real time according to network flow, connection of each node, load condition, distance to the user, response time and other comprehensive information. The method aims to enable the user to obtain the required content nearby, solve the problem of congestion of the Internet network and improve the response speed of the user for accessing the website.
The invention provides a method for using CDN acceleration service in a low-intrusion mode in a Java Web program. FIG. 1 is a flow chart of one embodiment of the present invention. As shown in fig. 1, the CDN acceleration service method of the present invention includes the following steps:
1) after receiving an access request sent by a user side, the Java Web judges whether a system configuration switch starts the CDN or not, if the CDN is started, the step 2) is carried out, and if not, the original page is returned;
2) configuring a filter in a Java Web application program to enable a target page to use CDN service;
and detecting whether a link of the resource file exists in the filter, and if so, replacing the link of the resource file with the CDN service link. Where the access request may be a user's web page request, video request, audio request, etc.
Nowadays, web projects pay attention to optimizing user experience, the important aspect of the user experience is the response speed of pages, and nowadays, many rely on CDN networks to accelerate the access of a user terminal. The invention provides a global switch for judging whether the CDN is started or not, and the CDN service can be integrated. The configuration filter is the basis for providing a global switch. If no filter exists, the CDN acceleration service cannot be used in a low-intrusion mode, only the CDN acceleration service can be used in a high-intrusion mode, and code change is large.
In the method of the present invention, step 1) may further comprise: and detecting whether the CDN service address is not null and starts with http, if not, transferring the access request to the original page, and if so, entering the step 2). The judgment logic is equivalent to a CDN judgment switch, and the access of the CDN of the switch can be flexibly judged, the CDN service domain name can be replaced, and all resource links do not need to be rewritten.
In the method of the present invention, the filter may be configured such that the target page is a page including the first character string as a head. The target page may be a page that the customer wishes to replace with a CDN service. The first string refers to the access address prefix. Since most of the commonly provided web pages have some resources beginning with the prefix of the current access address, the web pages are resources of the current site.
The target page is set to be the page containing the first character string as the beginning, so that the page which does not need to use the CDN service can be filtered, and the efficiency of the CDN service is greatly improved.
In the method of the invention, the filter can acquire the media type according to the user request and judge whether the type is in an HTML format. The media type may be a resource such as a page, music, video, etc. The resources are hung under codes in an HTML format and are equivalent to a total control layer.
In the method of the present invention, the step of replacing the link of the resource file to the CDN service link may be:
(a) acquiring a page code according to an access request of a user;
(b) acquiring the prefix of the access request address;
(c) and splicing the obtained prefix of the access request address with a CDN service address prefix to obtain the CDN service link. The above steps are also the program logic for the filter of the present invention.
The system of the invention can realize CDN acceleration service by adopting a low-intrusive mode with less code change when a frame or a module is removed.
In order to make the aforementioned objects and advantages of the present invention comprehensible, embodiments accompanied with figure 1 are described in detail
1) Referring to fig. 1, a detailed flow chart of the method of the present invention is shown, which includes the following:
(1) firstly, a user request is obtained
(2) See if the configuration has opened CDN service
(3) Directly jumping to the original page without opening
(4) Entering a custom filter to replace the resource link when the CDN is judged to be started
(5) CDN service page which is displayed to user after being processed after replacement is completed
2) The following is a specific code logic flow of the present invention
The Java Web receives an access request sent by a user side, the Java Web obtains request page information of the user by intercepting a user request, and a filter is configured in a Java Web application program, wherein the configuration is added in web.xml, and the filter is set:
Figure BDA0002516317630000051
Figure BDA0002516317630000061
the filter is configured to make the target page a page containing the first character string as a start. The url-pattern setting/' is to intercept all requests, which is equivalent to using CDN service pages for all pages. Example (c): it is also possible to set/item/, which represents intercepting the request beginning with the item/item in the request address, and it is equivalent to using the CDN service page only for the page requested at the beginning with the item/item).
The step is to add a filter in the project configuration file, which is mainly used for intercepting the user request and entering the logic processing of the filter.
(2) Xml configures CDN address and text to be replaced
Suffix of piece
< CDNSetting cdnDomain ═ set CDN address "expand ═ js/, css/, image/"/>
The method mainly provides a global switch which is mainly used for providing a global resource link replacement address and control of specified resource replacement for the method, sets a CDN service address to be replaced and a resource file suffix to be replaced in a configuration file, and then can acquire information configured in a program.
(3) The Filter interface is implemented in the Filter, which is mainly used for further processing the intercepted request, and the program logic is implemented in the doFilter method, because the intercepted request enters the method
(4) Acquiring CDNSetting labels in the configuration files, respectively taking out values corresponding to cdnDomain and expand, wherein the cdnDomain parameter is set to be a CDN service address, and the expand parameter is set to be a file suffix needing to be replaced
(5) And judging whether the CDN is started by the system configuration switch. And judging whether the obtained cdnDomain value is not null or not, and starting with http. If the obtained cdnDomain value is not null and begins with http, the CDN is started as a condition; if the cdndmain value is null and does not start with http, the condition is not met, and the request is forwarded to the original page. The cdnddomain can be set as a link not beginning with http, which means that the CDN service is closed, or the configuration tag can be removed
(6) Whether a link of the resource file exists is detected in the filter. Judging whether the media type information in the request is not null, and the type is in an HTML format, if not, writing the output stream to jump to the original page, filtering unnecessary requests, and acquiring the page source code by the request in the HTML format
(7) And replacing the link of the resource file to the CDN service link. If the above are all satisfied, executing:
get the source code of the requested page
Obtain the prefix of the access request address
Bulk replace the cdnDomain parameter if
Example 1:
http://dddd.cn/js/
http://dddd.cn/css/
http://dddd.cn/image/
example 2:
https://prod.cdn.cn/js/
https://prod.cdn.cn/css/
https://prod.cdn.cn/image/
(processing the acquired page source code, and replacing all the addresses corresponding to the original addresses in example 1 with the addresses using cdnDomain in example 2)
(8) Returning the processed page source code to the front end
(9) The request logic ends and the user actually sees the processed CDN
Service page
Detailed implementation steps and descriptions of the invention
1) Adding a filter in the project configuration file, wherein the filter is mainly used for intercepting a user request and entering the logic processing of the filter;
2) setting a CDN service address to be replaced and a resource file suffix to be replaced in a configuration file, and mainly providing a global resource link replacement address and control of specified resource replacement for the method;
3) implementing a Filter interface in a class specified by the configured Filter, wherein the Filter interface is mainly used for further processing the intercepted request;
4) firstly, a configured CDN service address is obtained, whether the address is empty or not is judged, or the address is not the beginning of http, if yes, processing logic is directly skipped, and an original page is returned, wherein the processing logic is equivalent to a CDN judgment switch;
5) acquiring a media type according to a user request, judging whether the type is in an HTML format, if so, entering the next step, wherein the step is used for filtering useless requests;
6) acquiring a page code according to the request, acquiring a request address prefix, splicing the CDN service address prefix, and then performing full text replacement on the acquired page code;
7) and returning and displaying the page code after the replacement processing to the user.
The invention integrates CDN service by providing a global switch for judging whether the CDN is started or not in a low-intrusion mode with less code change when a frame or a module is removed. The invention greatly simplifies the process of accessing the CDN service, can flexibly judge the access of the CDN and replace the CDN service domain name in actual use without rewriting all resource links.
The invention also provides a system for using CDN acceleration service in a low-intrusion mode in a Java Web program, which comprises the following steps:
a receiving unit, configured to receive an access request of a user side;
a filtering unit, configured to filter out undesired requests and identify a target page that is desired to use the CDN service;
and the replacing unit is used for replacing the link of the target page to the CDN service link.
In the system of the present invention, the filtering unit may be configured to identify the target page as being in HTML format.
In the system of the invention, the filtering unit may also detect whether the CDN service address is not empty and starts with http.
It should be understood that embodiments of the present invention may include additional, fewer, or different components than those shown in the figures. It will be appreciated that the features of the embodiments of the device of the invention may be a combination of different configurations.
Although the present invention has been described in detail with reference to the drawings for the purpose of illustration and description, it is to be understood that the disclosed methods and apparatus of use are not to be construed as limiting the invention. It will be readily apparent to those skilled in the art that various modifications to the foregoing embodiments may be made without departing from the scope of the invention.

Claims (8)

1. A method for using CDN acceleration service in a Java Web program in a low-intrusion mode comprises the following steps:
1) after receiving an access request sent by a user side, the Java Web judges whether a system configuration switch starts the CDN or not, if the CDN is started, the step 2) is carried out, and if not, the original page is returned;
2) configuring a filter in a Java Web application program to enable a target page to use CDN service;
and detecting whether a link of the resource file exists in the filter, and if so, replacing the link of the resource file with the CDN service link.
2. The method of claim 1, wherein step 1) further comprises: and detecting whether the CDN service address is not null and starts with http, if not, transferring the access request to the original page, and if so, entering the step 2).
3. The method of claim 1, wherein the filter is configured to make the target page a page containing a first string as a start.
4. The method of claim 3, wherein the filter obtains the media type according to the user request, and determines whether the media type is in HTML format.
5. The method of claim 1 wherein the step of replacing the link of the resource file to the CDN service link comprises:
(a) acquiring a page code according to an access request of a user;
(b) acquiring the prefix of the access request address;
(c) and splicing the obtained prefix of the access request address with a CDN service address prefix to obtain the CDN service link.
6. A system for low-intrusive use of CDN acceleration services in Java Web programs, comprising:
a receiving unit, configured to receive an access request of a user side;
a filtering unit, configured to filter out undesired requests and identify a target page that is desired to use the CDN service;
and the replacing unit is used for replacing the link of the target page to the CDN service link.
7. The system of claim 6, wherein the filtering unit is configured to identify the target page as being in HTML format.
8. The system of claim 6, wherein the filtering unit further detects whether the CDN service address is not empty and begins with http.
CN202010477535.3A 2020-05-29 2020-05-29 Method and system for using CDN acceleration service in Java Web program in low-intrusion mode Pending CN111736926A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010477535.3A CN111736926A (en) 2020-05-29 2020-05-29 Method and system for using CDN acceleration service in Java Web program in low-intrusion mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010477535.3A CN111736926A (en) 2020-05-29 2020-05-29 Method and system for using CDN acceleration service in Java Web program in low-intrusion mode

Publications (1)

Publication Number Publication Date
CN111736926A true CN111736926A (en) 2020-10-02

Family

ID=72648021

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010477535.3A Pending CN111736926A (en) 2020-05-29 2020-05-29 Method and system for using CDN acceleration service in Java Web program in low-intrusion mode

Country Status (1)

Country Link
CN (1) CN111736926A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092581A (en) * 2011-10-28 2013-05-08 阿里巴巴集团控股有限公司 Method and device for setting up Web front-end local development environment
CN106603734A (en) * 2015-10-16 2017-04-26 任子行网络技术股份有限公司 CDN service IP detection method and system
CN107465654A (en) * 2016-08-31 2017-12-12 哈尔滨广播电视台 For content distribution between each business subnet of TV and Radio Service and the system of safe killing
CN108804514A (en) * 2018-04-25 2018-11-13 网宿科技股份有限公司 A kind of webpage loading method, server and webpage loading system
CN109670131A (en) * 2018-12-18 2019-04-23 网宿科技股份有限公司 The processing of Resource Description File, the acquisition methods of page resource and intermediate server
CN109981595A (en) * 2019-03-05 2019-07-05 网宿科技股份有限公司 A kind of resource acquiring method, resource return method and server, storage medium
CN110830537A (en) * 2018-08-13 2020-02-21 阿里巴巴集团控股有限公司 Page processing method and device

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092581A (en) * 2011-10-28 2013-05-08 阿里巴巴集团控股有限公司 Method and device for setting up Web front-end local development environment
CN106603734A (en) * 2015-10-16 2017-04-26 任子行网络技术股份有限公司 CDN service IP detection method and system
CN107465654A (en) * 2016-08-31 2017-12-12 哈尔滨广播电视台 For content distribution between each business subnet of TV and Radio Service and the system of safe killing
CN108804514A (en) * 2018-04-25 2018-11-13 网宿科技股份有限公司 A kind of webpage loading method, server and webpage loading system
CN110830537A (en) * 2018-08-13 2020-02-21 阿里巴巴集团控股有限公司 Page processing method and device
CN109670131A (en) * 2018-12-18 2019-04-23 网宿科技股份有限公司 The processing of Resource Description File, the acquisition methods of page resource and intermediate server
CN109981595A (en) * 2019-03-05 2019-07-05 网宿科技股份有限公司 A kind of resource acquiring method, resource return method and server, storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
赵琬清;张沛;马严;: "面向网站服务的CDN服务发现方法研究", 中国教育网络, no. 01 *

Similar Documents

Publication Publication Date Title
US8892680B2 (en) System and method for caching content elements with dynamic URLs
US8769397B2 (en) Embedding macros in web pages with advertisements
US8126986B2 (en) Advanced content and data distribution techniques
CN104063460B (en) A kind of method and apparatus loading webpage in a browser
CA2734774C (en) A user-transparent system for uniquely identifying network-distributed devices without explicitly provided device or user identifying information
US8452925B2 (en) System, method and computer program product for automatically updating content in a cache
US20110055386A1 (en) Network analytics management
US9871850B1 (en) Enhanced browsing using CDN routing capabilities
CN104714965B (en) Static resource De-weight method, static resource management method and device
US20080243634A1 (en) Providing website hosting overage protection by transference to an overflow server
KR101560185B1 (en) Method for controlling device using URL in distributed network environment and apparatus thereof
JP2012508914A (en) Page resource processing method and apparatus
CN103001964B (en) Buffer memory accelerated method under a kind of LAN environment
CN102737116A (en) Method and device for storing webpage resources
CN111478935A (en) Resource access method, internetwork connecting device, system and device
CN106557584A (en) A kind of web site collection method and device
CN107526748B (en) Method and equipment for identifying user click behavior
US10187319B1 (en) Automatic configuration generation for a proxy optimization server for optimizing the delivery of content of a web publisher
US20070055663A1 (en) Programmatic response for detected variants of HTTP requests
CN102833241B (en) Streaming media service traffic record merged-processing method and device
CN103354546A (en) Message filtering method and message filtering apparatus
JP2002183019A (en) Cache device
CN111736926A (en) Method and system for using CDN acceleration service in Java Web program in low-intrusion mode
JP2007527067A (en) Hierarchical distribution of UI assets
WO2015176659A1 (en) System and method for pre-fetching

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination