CN113630434A - Processing method for client access request and server - Google Patents

Processing method for client access request and server Download PDF

Info

Publication number
CN113630434A
CN113630434A CN202110681957.7A CN202110681957A CN113630434A CN 113630434 A CN113630434 A CN 113630434A CN 202110681957 A CN202110681957 A CN 202110681957A CN 113630434 A CN113630434 A CN 113630434A
Authority
CN
China
Prior art keywords
server
access request
request
static
dynamic resource
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
CN202110681957.7A
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.)
Towatt Energy Technology Co ltd
Original Assignee
Towatt Energy 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 Towatt Energy Technology Co ltd filed Critical Towatt Energy Technology Co ltd
Priority to CN202110681957.7A priority Critical patent/CN113630434A/en
Publication of CN113630434A publication Critical patent/CN113630434A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention provides a processing method for a client access request, which is applied to a server, wherein the server comprises the following steps: a Nginx server for caching static resources and a Tomcat server for caching dynamic resources. By applying the scheme provided by the embodiment of the invention, the Nginx server can automatically identify the dynamic resource access request and the static resource access request when the client requests access, if most of pages requested to be accessed by the client are static files such as pictures, the Nginx server can directly display the dynamic resource access request and if the content requested to be accessed by the client comprises a dynamic link, the Nginx server can be called through the Tomcat server, and the Tomcat server are responsible for the dynamic link and the static link, so that the dynamic and static separation is realized, and the performance of the server for processing the request is improved.

Description

Processing method for client access request and server
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method for processing a client access request and a server.
Background
At present, the release of web projects is usually completed by a Tomcat server, which belongs to a lightweight application server and is commonly used in small and medium-sized systems and occasions where concurrent access users are not many.
However, since the reading reaction speed of the Tomcat server to the static file is slow, the corresponding speed of the server to the static access request of the client is slow.
Disclosure of Invention
The embodiment of the invention provides a processing method for a client access request and a server, so as to achieve the technical effect of improving the processing speed of the access request.
In one aspect of the present invention, a method for processing a client access request is provided, which is applied to a server, where the server includes: the Nginx server used for caching the static resource and the Tomcat server used for caching the dynamic resource, and the processing method comprises the following steps:
the Nginx server receives an access request sent by a client and determines a static resource access request and a dynamic resource access request in the access request;
the Nginx server forwards the dynamic resource access request to the Tomcat server based on a reverse proxy principle;
the Nginx server searches static resources corresponding to the static resource access request in the static resources cached by the Nginx server;
after receiving the dynamic resource access request, the Tomcat server searches for the dynamic resource corresponding to the dynamic resource access request from the dynamic resource cached by the Tomcat server.
Compared with the prior art, the invention has the beneficial effects that: by applying the scheme provided by the embodiment of the invention, the Nginx server can automatically identify the dynamic access request and the static access request when the client requests access, if most of pages requested to be accessed by the client are static files such as pictures, the Nginx server can directly display the static access request, if the client requests access including dynamic links, the Nginx server can be called through the Tomcat server, and the dynamic access request and the Tomcat server are responsible for realizing dynamic and static separation and improving the performance of the server processing request.
Optionally, the static resource access request includes: the method comprises the steps of a hypertext markup language (HTML) request, an IMG format file request, a JS script request and a Cascading Style Sheet (CSS) request.
Optionally, the dynamic resource access request includes: a JSP request, a Servlet request and a data read-write request.
Optionally, the static resource is cached in the/usr/local/webpps directory of the Nginx server.
Optionally, the dynamic resource is cached under webpps/web/directory of the Tomcat server.
In another aspect of the present invention, an electronic device is further provided, which includes a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing processor-executable instructions;
and the processor is used for realizing the processing method aiming at the client access request when executing the instruction stored in the memory.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the principles of the invention. In the drawings:
fig. 1 is a schematic flowchart of a processing method for a client access request according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail with reference to the following embodiments and accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
Referring to fig. 1, a processing method for a client access request provided in an embodiment of the present invention is applied to a server, where the server includes: the Nginx server used for caching the static resource and the Tomcat server used for caching the dynamic resource, and the processing method comprises the following steps:
s100, the Nginx server receives the access request sent by the client and determines a static resource access request and a dynamic resource access request in the access request.
The Nginx server is a high-performance HTTP and reverse proxy web server and also provides IMAP/POP3/SMTP service; its advantages are less occupied internal memory and high concurrency.
In implementation, the number of the servers may be 1 or more, and in the case of 1, the Nginx server and the Tomcat server are installed in the same server; in the case of a plurality of servers, the Nginx server and Tomcat server may be installed in different servers.
In an implementation, the static resource access request may include: the method comprises the steps of a hypertext markup language (HTML) request, an IMG format file request, a JS script request and a Cascading Style Sheet (CSS) request.
The dynamic resource access request may include: a JSP request, a Servlet request and a data read-write request.
The English name of HTML is Hyper Text Markup Language (HTML), i.e., hypertext Markup Language. HTML, which is a language for creating web documents and displays contents such as video, sound, pictures, character animation, and video through a Tag-type command (Tag), is used as an information presentation language of WWW, and a document described using the HTML language is required to be displayed through a WWW browser.
The IMG format is a format of an image file, which has high compression efficiency, and supports an image of an arbitrary size.
JavaScript, JS for short, is a lightweight, interpreted or just-in-time programming language with function preference.
CSS is a computer language used to represent file styles such as HTML (an application of the standard universal markup language) or XML (a subset of the standard universal markup language).
JSP, JavaServerPages deploys on the network server, can respond to the request sent by the client, and dynamically generates a Web page of HTML, XML or other format documents according to the content of the request.
Servlet is a short name of JavaServlet, is a Servlet or a service connector, and a server-side program written by Java has the characteristic of being independent of a platform and a protocol, and has the main functions of interactively browsing and generating data and generating dynamic Web content.
S110, the Nginx server forwards the dynamic resource access request to the Tomcat server based on the reverse proxy principle.
The reverse proxy is that the Nginx server is used as a proxy server to receive the access request of the client, and then the access request is forwarded to a Tomcat server on the internal network; and returns the result obtained from the Tomcat server to the client that sent the access request.
S120, the Nginx server searches the static resource corresponding to the static resource access request in the static resource cached by the Nginx server.
In implementation, static resources may be cached in the/usr/local/webapps directory of the Nginx server.
S130, after receiving the dynamic resource access request, the Tomcat server searches the dynamic resource corresponding to the dynamic resource access request in the dynamic resource cached by itself.
In an implementation, the dynamic resource may be cached under the webpps/web/directory of the Tomcat server.
The first embodiment is as follows:
prepare an os server of Centos 7.6, configure firewall to open 8080 port pass.
Downloading the JDK compression packet, wherein the path after decompression is as follows: the method comprises the following steps of/usr/local/java, and environment variables are configured in the system, wherein the environment variables comprise: and environment variables such as JAVA _ HOME, PATH, CLASSPATH and the like, and the restarting server takes effect.
Installing Nginx on line in a linux system, configuring a front-end access port to be 8080, and configuring boot self-starting.
Downloading an installation package of Tomcat, decompressing, wherein the path is/usr/local/Tomcat, the distribution port is 8080, and the program is started up and started up automatically.
Jsp dynamic page is established, and the function of the code is to display the current time in real time and load a static picture.
Creating a folder of web/img/in Tomcat root directory webapps for storing pictures, and copying a test.jpg graph into the folder with the following path: jpg/webpps/web/img/test
After starting Tomcat, the browser enters the web address: jsp, http:// IP:8080/web/index. jsp, dynamic time is shown, as well as still pictures.
Nginx is configured, the access request is intercepted through configuration Location, all dynamic resource access requests are handed to Tomcat for processing, and other static resource access requests such as HTML, JS and CSS are processed by Nginx.
In the configuration code of the Nginx, a directory accessed by the Nginx is specified, namely the directory where the static resource is located is as follows: /usr/local/webapps, specifying that these static resources have a cache time of 30 days at the client browser.
An embodiment of the present invention further provides an electronic device, as shown in fig. 2, including a processor 001, a communication interface 002, a memory 003 and a communication bus 004, where the processor 001, the communication interface 002 and the memory 003 complete mutual communication through the communication bus 004,
a memory 003 for storing a computer program;
the processor 001 is configured to implement a method for processing a client access request when executing a program stored in the memory 003, and includes:
the Nginx server receives an access request sent by a client and determines a static resource access request and a dynamic resource access request in the access request;
the Nginx server forwards the dynamic resource access request to the Tomcat server based on a reverse proxy principle;
the Nginx server searches static resources corresponding to the static resource access request in the static resources cached by the Nginx server;
after receiving the dynamic resource access request, the Tomcat server searches for the dynamic resource corresponding to the dynamic resource access request from the dynamic resource cached by the Tomcat server.
Compared with the prior art, the invention has the beneficial effects that: by applying the scheme provided by the embodiment of the invention, the Nginx server can automatically identify the dynamic access request and the static access request when the client requests access, if most of pages requested to be accessed by the client are static files such as pictures, the Nginx server can directly display the static access request, if the client requests access including dynamic links, the Nginx server can be called through the Tomcat server, and the dynamic access request and the Tomcat server are responsible for realizing dynamic and static separation and improving the performance of the server processing request.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is 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 a process, method, 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 process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. Particularly, for the server-side embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for relevant points, reference may be made to part of the description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (6)

1. A processing method for a client access request is applied to a server, and the server comprises the following steps: the Nginx server used for caching the static resource and the Tomcat server used for caching the dynamic resource, and the processing method comprises the following steps:
the Nginx server receives an access request sent by a client and determines a static resource access request and a dynamic resource access request in the access request;
the Nginx server forwards the dynamic resource access request to the Tomcat server based on a reverse proxy principle;
the Nginx server searches static resources corresponding to the static resource access request in the static resources cached by the Nginx server;
after receiving the dynamic resource access request, the Tomcat server searches for the dynamic resource corresponding to the dynamic resource access request from the dynamic resource cached by the Tomcat server.
2. The processing method of claim 1, wherein the static resource access request comprises: the method comprises the steps of a hypertext markup language (HTML) request, an IMG format file request, a JS script request and a Cascading Style Sheet (CSS) request.
3. The processing method of claim 1, wherein the dynamic resource access request comprises: a JSP request, a Servlet request and a data read-write request.
4. The process of claim 1, wherein static resources are cached in the/usr/local/webpps directory of the Nginx server.
5. The process of claim 1, wherein the dynamic resource is cached under webpps/web/directory of the Tomcat server.
6. The server is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication among the processors and the memory through the communication bus;
a memory for storing processor-executable instructions;
a processor adapted to perform the method steps of any of claims 1-5 when executing instructions stored in the memory.
CN202110681957.7A 2021-06-19 2021-06-19 Processing method for client access request and server Pending CN113630434A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110681957.7A CN113630434A (en) 2021-06-19 2021-06-19 Processing method for client access request and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110681957.7A CN113630434A (en) 2021-06-19 2021-06-19 Processing method for client access request and server

Publications (1)

Publication Number Publication Date
CN113630434A true CN113630434A (en) 2021-11-09

Family

ID=78378169

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110681957.7A Pending CN113630434A (en) 2021-06-19 2021-06-19 Processing method for client access request and server

Country Status (1)

Country Link
CN (1) CN113630434A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104618508A (en) * 2015-02-26 2015-05-13 浪潮电子信息产业股份有限公司 Load balancing mesh architecture based on Nginx, Memcached and Tomcat
CN105956030A (en) * 2016-04-25 2016-09-21 浪潮电子信息产业股份有限公司 WEB system and WEB request processing method
CN106685932A (en) * 2016-12-08 2017-05-17 努比亚技术有限公司 File access system and method based on cloud service
CN111277629A (en) * 2020-01-13 2020-06-12 浙江工业大学 High-availability-based web high-concurrency system and method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104618508A (en) * 2015-02-26 2015-05-13 浪潮电子信息产业股份有限公司 Load balancing mesh architecture based on Nginx, Memcached and Tomcat
CN105956030A (en) * 2016-04-25 2016-09-21 浪潮电子信息产业股份有限公司 WEB system and WEB request processing method
CN106685932A (en) * 2016-12-08 2017-05-17 努比亚技术有限公司 File access system and method based on cloud service
CN111277629A (en) * 2020-01-13 2020-06-12 浙江工业大学 High-availability-based web high-concurrency system and method

Similar Documents

Publication Publication Date Title
CN109683998B (en) Internationalization realization method, device and system
US9021367B2 (en) Metadata capture for screen sharing
WO2016173200A1 (en) Malicious website detection method and system
CN109815430B (en) Request processing method and device, data processing server and readable storage medium
US8682964B1 (en) Progressively loading network content
US8516041B1 (en) Pre-fetching asynchronously requested content
CN105095280A (en) Caching method and apparatus for browser
WO2012178167A2 (en) Methods for making ajax web applications bookmarkable and crawlable and devices thereof
WO2023093673A1 (en) Information processing method, apparatus and system, and storage medium
US8839126B1 (en) Secure HTML components for building client-side user interface
CN112637361B (en) Page proxy method, device, electronic equipment and storage medium
CN113382083B (en) Webpage screenshot method and device
US9122484B2 (en) Method and apparatus for mashing up web applications
US8195762B2 (en) Locating a portion of data on a computer network
CN111431767A (en) Multi-browser resource synchronization method and device, computer equipment and storage medium
CN111783005B (en) Method, device and system for displaying web page, computer system and medium
CN113094612A (en) Method and device for loading webpage at client, electronic equipment and medium
JP2009031960A (en) Technology for relaying communication between client device and server device
JP5535184B2 (en) Browser execution script conversion system and browser execution script conversion program
CN113630434A (en) Processing method for client access request and server
CN113127788B (en) Page processing method, object processing method, device and equipment
US10990750B2 (en) Dynamically bundling web page resources
US9223758B1 (en) Determining a language encoding data setting for a web page, and applications thereof
CN111783006A (en) Page generation method and device, electronic equipment and computer readable medium
US11630879B2 (en) Server and providing method

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